I have a repository in Git. I made a branch, then did some changes both to the master and to the branch.
Then, tens of commits later, I realized the branch is in muc
Edit: You didn't say you had pushed to a public repo! That makes a world of difference.
There are two ways, the "dirty" way and the "clean" way. Suppose your branch is named new-master
. This is the clean way:
git checkout new-master
git branch -m master old-master
git branch -m new-master master
# And don't do this part. Just don't. But if you want to...
# git branch -d --force old-master
This will make the config files change to match the renamed branches.
You can also do it the dirty way, which won't update the config files. This is kind of what goes on under the hood of the above...
mv -i .git/refs/new-master .git/refs/master
git checkout master