The project we are using had its master branch moved to main, on GitLab for reasons of consistency.
Locally I had renamed the master branch to main:
git branch -m master main
This seemed to be enough until I accidentally did git checkout master and then it recreated the master branch. Doing a git branch -a, I see I now have the following two remotes (in addition to my other ones):
remotes/origin/main
remotes/origin/master
How do a tell the local repo to forget about remotes/origin/master, to avoid accidentally recreating master, when I mean to switch to the main branch?
First step would be to try:
git fetch --prune
If that does not work, it could mean the master branch is still on GitLab remote repository side (it could have been pushed by mistake by another developer who also checkout the wrong local master branch first)
In any case, once GitLab repository is clean, you can also add a pre-commit hook in order to prevent any future accidental checkout of the wrong branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With