1

I searched on my keyboard through latest commits in sourcetree and accidentally pressed something, window popped up, then I accidentally pressed enter, so I don't know what it said. As a result, I ended up with a detached HEAD. After some googling, I found an advice recommending to use "reset current branch on this commit" on the latest commit as a fix. Did that, but HEAD is still detached and bunch of other peoples commits got cancelled and are now in uncommited changes :(.

Found out detached head was created by checking out older commit.

1) Can I fix this in sourcetree?
2) Most importantly. Did I break the repository for the whole team or is only my local copy affected?

All help is very much appreciated, thank you.

Jan Kebrle
  • 11
  • 2
  • 3
  • 'I found an advice recommending to use "reset current branch on this commit" on the latest commit as a fix.' That probably wasn't the right thing to do. Which branch do you want to have checked out? Do you know what the hash of its latest commit should be? – ChrisGPT was on strike Jul 25 '16 at 16:47
  • 1
    You've been tripped up by something in a GUI, which makes it hard to know what *else* has been done (GUIs: hiding what they do since 1979! well, depends on the GUI). Meanwhile the *non*-GUI answer was in http://stackoverflow.com/questions/10228760/fix-a-git-detached-head?rq=1 (but you may need to do something else because of the extra intermediate thing-the-GUI-did). As for item 2, the good thing about Git is that except for `push` and `fetch` (and some rarer specia cases you won't be using), ***everything*** you do is local-copy-only. – torek Jul 25 '16 at 16:51
  • @Chris latest commit got moved to uncommited changes, about 7 of todays commits got cancelled, so the hash of the latest commit I would like to return to dissapeared – Jan Kebrle Jul 25 '16 at 16:57
  • @torek Thanks for your advice. I'll disable my vpn before trying to fix, so I dont do more harm. In the worst case, if I'll just delete my local copy and download clean version from git... – Jan Kebrle Jul 25 '16 at 16:59
  • From all these answers it is clear that hardly anyone uses Sourcetree. A very good answer is here. I tried it and it worked. https://community.atlassian.com/t5/Sourcetree-questions/Fix-a-detached-head-lost-master-branch/qaq-p/165563 – emorphus Nov 02 '21 at 07:30

0 Answers0