Skip to content

Instantly share code, notes, and snippets.

@JM-Mendez
Created July 9, 2020 20:16
Show Gist options
  • Save JM-Mendez/e9b1d4bb8d0a55bcc92142a1904dac60 to your computer and use it in GitHub Desktop.
Save JM-Mendez/e9b1d4bb8d0a55bcc92142a1904dac60 to your computer and use it in GitHub Desktop.
Autopush git repo on every commit
# adapted from https://stackoverflow.com/a/28042939
branch_name=$(git symbolic-ref --short HEAD)
retcode=$?
# Only push if branch_name was found (my be empty if in detached head state)
if [ $retcode -eq 0 ] ; then
#Only push if branch_name does not end with the non-push suffix
if [[ $branch_name != 'dev' && $branch_name != 'master' ]] ; then
echo
echo "**** Pushing current branch $branch_name to origin [post-commit hook]"
echo
git push origin $branch_name;
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment