Zolt
Zolt

Reputation: 2811

Detached HEAD in GitHub Git Client

I was about to check in some code to git hub using the UI client when I got some issue with a detached head. I am using the client, and I'm not familiar with the git shell. Before me, another developer checked in some code to the master, and afterwards I tried to check in my code, and got the issue.

It never happened before and I was able to always commit and sync changes. Then suddenly it came up when the other person committed changes before me. Besides new code, nothing else changed on my end.

Also, I have the below error.

Screenshot

Is there any simple, easy, quick way I can get rid of this detached head thing and get my code onto the main branch?

Upvotes: 2

Views: 2825

Answers (1)

VonC
VonC

Reputation: 1324937

The OP Frank solved it the "quick" way:

because of time constraints I just saved my uncommitted work, re-cloned the project, and updated it after.


You seem to have two issues:

  • you are in a detached HEAD
  • you won't be able to push since somebody already pushed before you

In both cases, opening a shell is advisable.
And backup your git repo first, in order to start over if those solutions don't work.

For the detached HEAD, following "Git: How can I reconcile detached HEAD with master/origin?":

git checkout temp
git checkout -B master temp

For the push:

git pull --rebase
(the refresh your GitHub GUI and you should be able to push)

If you still have a "Failed to load commit history" error message, check the GitHub GUI log.

Upvotes: 2

Related Questions