Skip to content
Discussion options

You must be logged in to vote

You can rename a branch both locally and remotely with the following steps:


I. Rename Locally

git branch -m dev-branch main-dev

This renames the branch you're currently on. If you're not on dev-branch, use:

git branch -m dev-branch main-dev

II. Push the Renamed Branch

git push origin main-dev

Then delete the old branch from the remote:

git push origin --delete dev-branch

III. Reset the Upstream Tracking

git push --set-upstream origin main-dev

IV. Update Default Branch on GitHub (Optional)
If this is a default branch, go to your repository’s Settings > Branches and set main-dev as the new default. Then delete the old one.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iAmRubayet1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development
2 participants