1

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.

ryanwils
  • 947
  • 7
  • 18
  • Have you tried checking out the HEAD branch again? `git checkout HEAD` – iltempo Feb 29 '12 at 06:27
  • I get "Your Branch and 'origin/ryan' have diverged, and have 1 and 6 different commit(s) each, respectively. Then nothing happens in Xcode at all. (ryan is the name of my branch I usually work on). Any ideas? (Thanks for the quick reply!) – ryanwils Feb 29 '12 at 06:45
  • Can you check if the commits you are missing are available on your origin repository? `git log HEAD..origin/ryan` Also see your last commit with `git show`. I'm I right that you need all of them? – iltempo Feb 29 '12 at 06:58
  • None of the commits are there at all... should I give up and redo it all? – ryanwils Feb 29 '12 at 07:06

1 Answers1

0

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.

Community
  • 1
  • 1
iltempo
  • 14,682
  • 8
  • 56
  • 70
  • I got the ability to push back, but unfortunately all my changes were gone. Looks like it'll be another late night... thanks for the help! – ryanwils Feb 29 '12 at 07:44