Rename Git branch with move


Rename or move a Git branch with the -m option:

git branch -m <newbranch>

This is useful when you accidentally commit to master:

git branch -m feature
git checkout master

Learn more about git branch with:

git branch --help


Please support this site and join our Discord!