A
A
afna2015-10-02 17:20:43
git
afna, 2015-10-02 17:20:43

How to restore commits from an unnamed branch?

Good evening!
I am using SourceTree.
I made a commit in develop. Then I did something in a hurry (This is my big mistake), which led to the creation of a branch that was unnamed, but on which there was HEAD. For several days I wrote changes (commits) to this unnamed branch.
And so I decided to switch to the develop branch. And damn it, the unnamed branch was gone, I ended up on the develop branch, my changes were lost.
The deadline is already on Monday, and here it is !!!
Can you please tell me how can I revert my changes from an unnamed branch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2015-10-02
@sulik93

Through git refloglooking for hashes of lost commits.
reflog displays all hashes where HEAD was.
And then:
Well, then go to develop (although you seem to be there anyway) and merge the lost changes:

git checkout develop
git merge new-branch-name

Naturally, all this must be done through the console.
The main thing is to do this in the repository where the commits were, and before git gc, otherwise the information about unreachable commits will be deleted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question