note: When you rename your git branches make sure you double check any connected CI jobs you have associated with the repository. Those will not be updated to use the new branch name.
checkoutthe branch you would like to rename:
git checkout my-outdated-branch.
- Use the
-mparameter to rename the branch:
git branch -m my-new-branch
note: You can also use
git branch -m my-outdated-branch my-new-branchto do the rename with a single command.
You can check the name of your branches using
git branch -a to list all local branches. For example:
If you’ve updated your branch name remotely already the change will not be reflected locally until you update your clone.
- Update your local branch to match the remote changes:
git branch -m my-outdated-branch my-new-branch
- Fetch the update
git fetch origin(if you’re using more than 1 remote, update
originin these commands to be the remote you are trying to sync with)
- Update the upstream of your local branch:
git branch -u origin/my-new-branch my-new-branch(This updates the upstream of your local
my-new-branchto point at
- Optional: If you are updating your
mainbranch you can use
git branch set-head origin -ato update the default branch of the