0

I had committed my changes on the local and then did accidentally did a checkout from remote branch and have lost all my changes! Help - is there anyway I can get back to my committed changes?

Nacha
  • 107
  • 1
  • 5

3 Answers3

3

git reflog

Look for your commit and do a checkout.

Sailesh
  • 25,517
  • 4
  • 34
  • 47
  • @Nacha - Can you tell what you did to solve? As in, the command. – manojlds Oct 27 '11 at 08:01
  • @manojlds: `git reflog` shows all the recent commit changes, including switching to different branches. One only needs to identify the required commit and just do `git checkout`. If the consequence is a detached state, then one may choose to cherry-pick the required commits, without having to retype all the work. – Sailesh Oct 27 '11 at 11:51
  • @Sailesh - I was expecting answer from OP. I know what git reflog does. – manojlds Oct 27 '11 at 14:01
1

Since you have committed your changes, you need not worry. Just do this:

git checkout -

it will take you back to the branch you were in.

manojlds
  • 290,304
  • 63
  • 469
  • 417
0

Fixing un-committed mistakes

If you've messed up the working tree, but haven't yet committed your mistake, you can return the entire working tree to the last committed state with

$ git reset --hard HEAD

Git Book