-1

I changed some files but don't use git add or git commit, it's just stay in working copy.
Then I use git reset --hard to force HEAD pointer to one previous commit. Currently, the files I changed before were discarded. So, my confusion is: Is there anyway to get the changes back?

Justin M. Ucar
  • 853
  • 9
  • 17
Allen
  • 6,745
  • 5
  • 41
  • 59

2 Answers2

1

Its not possible to get back uncommitted changes. Your best bet would be to try cached copies from editor or IDE.

nitishagar
  • 9,038
  • 3
  • 28
  • 40
0

As you used git reset --hard, both your index and working copy were reset.

git reset default behavior without an option is to keep your changes but as you explicitly asked git to reset the hard way, your changes were deleted. As far as I know there is now way to undo that.

edit : I did not try it, but using git reflog you may be able to see your changes before the reset. If you do, you can navigate through refs using git reset HEAD@{ref_number} e.g. git reset HEAD@{1}.