Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "fatal: You are on a branch yet to be born" mean in this context

Tags:

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

like image 207
Osada Lakmal Avatar asked Aug 16 '11 18:08

Osada Lakmal


People also ask

Why am I not getting master branch on GitHub?

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.

What does git branch command do?

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.

What is the git master branch?

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.


2 Answers

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.

like image 66
Andy Avatar answered Oct 03 '22 16:10

Andy


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.

like image 42
Luke Dupin Avatar answered Oct 03 '22 17:10

Luke Dupin