23

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

Zoe
  • 27,060
  • 21
  • 118
  • 148
Osada Lakmal
  • 891
  • 2
  • 8
  • 22
  • possible duplicate of [Why does my 'git branch' have no master?](http://stackoverflow.com/questions/3623755/why-does-my-git-branch-have-no-master) – tripleee Feb 27 '15 at 12:34

2 Answers2

12

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.

Andy
  • 44,610
  • 13
  • 70
  • 69
1

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.

Luke Dupin
  • 2,275
  • 23
  • 30