I was migrating a svn repo to git. I created a clean temp dir, used git svn init to get stuff in there and then added the remote and pushed it. Now on the other actual source dir (which I had cloned from the empty repo before committing stuff from svn) I did a fetch. And then I did a checkout and got above message. After a while I figured that I could get the source with a pull and did that. My question is what did that error message mean in that context ? How did I get that particular error message ? Disclaimer : I am a git newbie
Starting October 1, all new GitHub repositories will create a default branch named main, and GitHub will no longer create a master branch for you.
The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.
The master branch is a default branch in Git. It is instantiated when first commit made on the project. When you make the first commit, you're given a master branch to the starting commit point. When you start making a commit, then master branch pointer automatically moves forward.
I believe it was because your fetch, which only fetches remote refs and commits, didn't give you a local master branch to checkout. Since you were in an empty repo, you were never on a branch, so your git checkout
had no master branch to go to.
You could directly checkout the remote master by explicitly naming it with git checkout origin/master
but that will leave you in a detached head state.
Once you did the pull, it fetched and merged, the pull created a local master to track the remote master.
I was having the same error trying to migrate svn to git. Here was my fix.
Confirm you've initialized the git repo:
git init
Confirm you actually had a valid migration from svn:
git branch --remote #You should see this output: #git-svn
Create a detached head:
git checkout git-svn
Convert the detached head into the master branch:
git checkout -b master
At this point your git repo will function normally.
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