Run any program before Git | push to reduce mistakes


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.

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