Skip to content

Instantly share code, notes, and snippets.

@krazylegz
Created October 25, 2014 22:38
Show Gist options
  • Select an option

  • Save krazylegz/0a49ddee5ce0baf2d5c6 to your computer and use it in GitHub Desktop.

Select an option

Save krazylegz/0a49ddee5ce0baf2d5c6 to your computer and use it in GitHub Desktop.
repush () {
if [ -z "$1" ]
then
branch=$(git rev-parse --abbrev-ref HEAD)
else
branch=$1
fi
if [[ $branch != 'master' ]]
then
echo "Repushing $branch"
original_branch=$(git rev-parse --abbrev-ref HEAD)
git checkout $branch
git commit --amend -m "$(git log -1 --oneline | cut -d " " -f 2-)"
git push -f origin $(git rev-parse --abbrev-ref HEAD)
git checkout $original_branch
echo "Repushed $branch."
return 0
else
echo "Refusing to repush master."
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment