When switching back from a local branch, I accidentally checked out a new branch, MASTER, and pushed it to origin. Now the repo has master and MASTER as branches. How do I safely rename MASTER and rebase it into master?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s really no need to rename it. Simply merge or rebase your new changes in MASTER onto master, then delete the MASTER branch.
git merge master MASTERwill add a merge commit tomaster, along with the history of individual commits.If you’d rather do a rebase, use
git rebase master MASTER.After either one of those, run
git branch -d MASTERto delete your local MASTER branch. To delete the remote branch, rungit push origin :MASTER(via this page). And be sure to push it all to origin afterwards.Edit If you really do want to rename it, like if you maintain links to your topic branches, delete the remote branch, rename it locally using
git branch -M MASTER foobarand push it to the remote.