Skip to content

Instantly share code, notes, and snippets.

@mohsin
Created September 24, 2015 22:53
Show Gist options
  • Save mohsin/0a6d1944cbd7815e58e7 to your computer and use it in GitHub Desktop.
Save mohsin/0a6d1944cbd7815e58e7 to your computer and use it in GitHub Desktop.
function push() {
if [ -z "${1}" ]; then
echo "Usage: push <remote-name>"
return 1
fi;
GIT_DIR_="$(git rev-parse --git-dir)"
BRANCH="$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))"
PRE_PUSH="$GIT_DIR_/hooks/pre-push"
POST_PUSH="$GIT_DIR_/hooks/post-push"
test -x "$PRE_PUSH" &&
exec "$PRE_PUSH" "$BRANCH" "$@"
git push "$1" "$BRANCH"
test $? -eq 0 && test -x "$POST_PUSH" &&
exec "$POST_PUSH" "$BRANCH" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment