Skip to content

Instantly share code, notes, and snippets.

@glimberg
Created February 23, 2009 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glimberg/68811 to your computer and use it in GitHub Desktop.
Save glimberg/68811 to your computer and use it in GitHub Desktop.
Post Commit hook to automatically push to origin/branch
#!/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
@hedgehog
Copy link

Rather, try

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

HTH?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment