V
V
vixh2010-11-11 18:53:18
git
vixh, 2010-11-11 18:53:18

Restoring an uncommitted branch in git

How to restore the branch, I ran into such a situation.

Made a branch:
git checkout -b feature-xxx develop

In the branch, feature-xxx made multiple changes to the code without making a git commit, switched to develop:
git checkout develop

Git wrote that it modified the changed files in develop from feature-xxx. I did not need this, so I did:
git checkout - CHANGED_FILE

I checked how the program worked before the changes in feature-xxx. Returning to feature-xxx (git checkout feature-xxx) found that the changes were gone.

Two days of work down the drain or you can return the changes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
umcherrel, 2010-11-11
@umcherrel

yes, two days down the drain
in such a case, you need to use git stash

S
Sannis, 2010-11-12
@Sannis

> Two days of work
AND one commit? Do them more often. Anticipating your question and thinking that you did it for later uploading to a corporate repository or (God forbid) to SVN: if you want to make one commit - after finishing work on the branch, you can merge all the changes into one commit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question