public
Last active

Post Commit hook to automatically push to origin/branch

  • Download Gist
post-commit
Shell
1 2 3 4 5 6 7 8 9
#!/bin/sh
#
# A hook script that is called after a successful
# commit is made.
#
# Place this file in .git/hooks and chmod +x
 
BRANCH=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
git push origin $BRANCH

Rather, try

BRANCH=$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))

HTH?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.