The Grouparoo Blog
TLDR: This command will fully get rid of the
master branch after you've switched to using
git remote prune origin
What I was seeing was
git checkout master still referenced the existence of the old branch I had used. I needed to get rid of that old one so that it would be an error.
When you do so, you get this helpful screenshot from Github:
Those instructions typed out:
> git branch -m master main > git fetch origin > git branch -u origin/main main
I have also seen this one added:
> git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
However, I still had a problem. My fingers kept typing
git checkout master when I should now be typing
git checkout main.
I would get over that in time, except that it wasn't giving me an error even though this was not a local or remote branch:
> git checkout master Branch 'master' set up to track remote branch 'master' from 'origin'. Switched to a new branch 'master' > git checkout blah error: pathspec 'blah' did not match any file(s) known to git
I wanted to get the second result: an error. Then my fingers would learn what my heart and head knew was right.
The solution hint came from running this command:
> git branch -a * main remotes/origin/HEAD -> origin/main remotes/origin/any_old_branch remotes/origin/blog_config remotes/origin/main remotes/origin/master
So if I did
git checkout any_old_branch that would not error either even though that was not a local or remote branch.
The solution was to run
git remote prune origin:
> git remote prune origin Pruning origin URL: firstname.lastname@example.org:grouparoo/www.grouparoo.com.git * [pruned] origin/any_old_branch * [pruned] origin/blog_config * [pruned] origin/master
Now it is gone from
git branch -a and I get the expected result:
> git checkout master error: pathspec 'master' did not match any file(s) known to git
Tagged in Engineering Notes
See all of Brian Leonard's posts.
Brian is the CEO and co-founder of Grouparoo, an open source data framework that easily connects your data to business tools. Brian is a leader and technologist who enjoys hanging out with his family, traveling, learning new things, and building software that makes people's lives easier.
Learn more about Brian @ https://www.linkedin.com/in/brianl429
Stay up to date
We will let you know about product updates and new content.