Reputation: 3521
I had 2 commits in a detatched head. I tried to checkout master, in order to branch it and add the new commits, and now the 2 commits are gone. Is there any way to retrieve them?
the tree was :
commit a -> commit b master
commit a -> commit c -> commit d HEAD
I want d back.
As instructed in other questions, I have gotten the SHA-1 of the "lost" commits with
git reflog
How can I create a branch in a, and merge the 2 commits? Do I check out 'commit a' branch, and use merge with the SHA-1 of 'commit d' (the latest commit in the detatched head)?
Upvotes: 2
Views: 43
Reputation: 40506
If you know the SHA of commit d, you can create a new branch pointing to it by doing:
git branch new_branch thesha
Upvotes: 2