Search code examples
macosgithubbranchpushhead

GitHub for Mac Issue - Pushed to HEAD branch then switched


I have an emergency issue at hand. First off, yes, I realize this was a very silly mistake.

Earlier on, I had a sync conflict, solved it correctly, and moved on. I just put in about 4 hours of work, saved everything fine, and then went to push to GitHub (using GitHub for Mac client). When I did so, it said there was an error, and I noticed I was on a branch called "HEAD". I then clicked to switch branches, and immediately panicked as I realized all of my changes were gone (since I had switched branches).

Is there ANY way I can switch back to this and recover my information??

If anyone could please help, it'd be greatly appreciated!

Thanks.


Solution

  • Based on the very good explanation on what happened from master branch and 'origin/master' have diverged, how to 'undiverge' branches'? give the following merge a try:

    Check out a new branch based on you HEAD

    git checkout -b local_changes HEAD

    and try to merge the remote branch

    git merge origin/ryan

    You may experience some merge conflicts that you have to resolve depending on what changed on both sides. If all is fine bring the merges back into you ryan branch again.

    git checkout ryan

    git merge local_changes

    If everything works you should have all the changes in place be able to push again to your remote.