Git recover uncommitted changes

后端 未结 6 758
萌比男神i
萌比男神i 2020-12-06 11:52

I had a lot of local changes.

I just accidentally did

git merge another_branch
git reset --hard HEAD^

on a lot of work. :( with the

相关标签:
6条回答
  • 2020-12-06 12:02

    Although the uncommitted modifications to tracked files will have been lost, I think any untracked files will still be around unless you subsequently deleted them.

    0 讨论(0)
  • 2020-12-06 12:04

    If the changes had never been committed/stashed/staged, then you're out of luck. If they have, then you should be able to git your changes back by looking for them in git reflog.

    0 讨论(0)
  • 2020-12-06 12:15

    look into Recycle Bin! I found my deleted(uncommitted) files there

    0 讨论(0)
  • 2020-12-06 12:17

    Try undoing on the file directly from the IDE. You'll get what you need.

    Probably not helpful for @Lakshman Prasad, but will help someone else :-D

    0 讨论(0)
  • 2020-12-06 12:19

    i was able to recover my files, by using git log -g my changes were there because i committed them once and then uncommitted my changes and then i saw all files on which i was working are lost,

    by doing git log -g || git reflog -g wil display recent commit logs,

    i found my commit hash and i checkout to that using this command git reset #commitHashID

    this may help someone with similar scenario

    0 讨论(0)
  • 2020-12-06 12:21

    Foy anyone who is facing this problem in ide's, there is a solution. Search For the ide editor history files of your ide. I had a problem with android studio so here i will give you a solution for android studio.

    For eg: In android studio you can always see the previous files , by right clicking on project folder->LOcal History->Show History.

    You can see the change history of files and you can also open the files and compare it with new files side by side. If you need old code just copy paste it from there.

    0 讨论(0)
提交回复
热议问题