9

I'm not entirely sure of the steps that caused this however I have ended up without my GIT master branch.

I had a crack at fixing things using the instructions here: http://sitaramc.github.com/concepts/detached-head.html however my general ignorance of GIT may have left me in a worse pickle than I started out.

$ git branch
  first-cucumber-attempt
  notifications
* second-cucumber-attempt
  sendgrid-setup

At some point I apparently started working on a detached HEAD and now I don't know how to find my master (I feel a little like Alice right now).

Attempting to checkout master gives:

$ git checkout master
  error: pathspec 'master' did not match any file(s) known to git.

Attempting to pull master gives:

$ git pull origin master
From github.com:petenixey/kind-advice
 * branch            master     -> FETCH_HEAD
Already up-to-date.

The branch, "second_cucumber_attempt" has all of the code I want to merge into master and master is still safe on github but I can't get to it. I am thoroughly stuck.

Cascabel
  • 479,068
  • 72
  • 370
  • 318
Peter Nixey
  • 16,187
  • 14
  • 79
  • 133

1 Answers1

17

The "master" in git checkout master is supposed to be a branch, which you do not have. You can checkout the remote's master and make it your own with git checkout origin/master -b master, which should also set it up as a "tracking branch".

You can see your list of remote branches with git branch -r.

wnoise
  • 9,764
  • 37
  • 47
  • 1
    I hit a subsequent problem when trying to push the repository up to github (error: src refspec remote does not match any.) however that was solved by this stackoverflow question: http://stackoverflow.com/questions/959477/error-when-git-push-to-github – Peter Nixey Jan 13 '11 at 11:55