-2

First am sorry for my english (BAD)

Can someone help me ? i was code so much modules here with my team but when i wanna go to push i was pull my friend code before.. i see favicon was merge, then i ignore that then i pull (overwritten)

but when finish the pull i forgot my code so much overwritten here :( can i get my last work? is there any way to save my code before ? i was pull overwrite but i haven't save it, hopefully there's a way to get my lastest save code i use sublime text editor

  • Given the quality of your question, I'm not surprised that you are confused about Git. In general, a hard reset cannot be undone. A heavy duty IDE like IntelliJ would have a local history for each file onto which you might be able to fall back after an accidental reset. Not sure about Sublime Text. – Tim Biegeleisen Jul 06 '17 at 10:41
  • Possible duplicate of [How can I undo git reset --hard HEAD~1?](https://stackoverflow.com/questions/5473/how-can-i-undo-git-reset-hard-head1) – garfbradaz Jul 06 '17 at 13:17

1 Answers1

1

Assuming you committed your work (even if you never pushed it), and assuming that you still have the specific repository in which you originally did the work, you can probably recover your work using the reflog. The reflog doesn't last forever, so this needs to be done soon after the work was "lost".

(If you did not commit your work - i.e. if it was only in your working tree and got lost before you did git add and git commit - then git does not have a record of it and you would have to rely on backups or other solutions outside of git. And reflogs are local to a specific repo. Neither reflogs nor "dangling commits" are typically shared during push/fetch/clone/etc.; and you need both of those things if you're going to recover anything.)

Anyway, if you say

git reflog

it will show a list of the commits that have recently been "the current commit". If you can find the last commit you made, you can recover it (e.g. by creating a new branch with that SHA1 as the starting point).

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52