🖥

Run any program before Git | push to reduce mistakes

2019/04/16に公開

Solution

Register the command you want to run before push as a git alias.

 [push] default = current [alias] before-push = !bundle exec rubocop && bundle exec rake notes && echo 'sleep 10 seconds and you will push' && sleep 10 gentle-push = !git before-push && git push 

Then you can use $ git gentle-push .

Above is an example of running rubocop (Ruby's grammar checker) and notes (a task that finds annotations).

result

Like this.

image

image

Description

  • Sleeping for 10 seconds is to allow Command + C to exit when something goes wrong. Note that it does not stop automatically.
  • I want you to rewrite necessary parts timely. For example, make push be push -f.

combination

It would be nice to put an alias that rebases the current branch into the "latest master" with one command in before-push.

 [push] default = current [alias] new-world = !git checkout master && git pull origin master && git checkout - && git rebase master before-push = !git new-world && bundle exec rubocop && bundle exec rake notes && echo 'sleep 5 seconds and you will push' && sleep 5 

problem

Often you forget what you want to run before push. It is better to understand the mistake at hand.

environment

  • git version 2.3.8 (Apple Git-58)
  • Mac OSX Yosemite

Original by

Git | push の前に任意のプログラムを走らせてミスを減らす

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-16

Discussion