Skip to content

Instantly share code, notes, and snippets.

@0livare
Last active August 14, 2018 13:54
Show Gist options
  • Save 0livare/d69c6ded2b8e9fb301d70f851d95a3e8 to your computer and use it in GitHub Desktop.
Save 0livare/d69c6ded2b8e9fb301d70f851d95a3e8 to your computer and use it in GitHub Desktop.
Move a local branch to a different commit
#!/bin/bash
# FOR ANYONE READING THIS, simply use 'git branch -f`, it even has the same syntax as this script
# If there are 0 or 1 arguments
if [ $# -eq 0 ] || [ $# -eq 1 ]
then
echo "Usage: git move <BRANCH-NAME> <BRANCH-POINTER>"
exit 1
fi
git branch -D $1
git branch $1 $2
echo ""
echo "Branch $1 moved to $2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment