0

Here is my situation:

  • I made some local changes
  • I added it to staging (git add .) and committed locally
  • Now I wanted to change the commit message so I thought I would discard that commit and do a new commit with updated message, so I searched (of course didn't searched properly) and in haste I did git reset --hard origin/master and all my local changes are lost.

Is there any way out, is there any GIT command which can help be get back my local changes?

My 3 hour work is on stake, please do let me know if there is any way out.

pjj
  • 2,015
  • 1
  • 17
  • 42
  • The good news is that most likely, the commit is still on disk. Before you start hacking, make a complete copy of the entire repository, including the `.git` folder and the current working directory. Then, afterwards, do a `git reflog` in the original repository and then see if the most recent commit you had on your local master is listed, if it is, then do a `git checkout `, and see if you're back to where you were. Then post an update here (and don't do anything else in the meantime) – Lasse V. Karlsen Dec 08 '18 at 19:02
  • Afterwards we can solve the "change the commit message" issue, but let's first get you back to where you were. – Lasse V. Karlsen Dec 08 '18 at 19:05
  • @LasseVågsætherKarlsen Thanks a lot, it worked. May be you can put this is answer as it answers what I was looking for. – pjj Dec 08 '18 at 19:06
  • No, I won't do that. I'm really happy it worked for you though, but this is a duplicate question, you're not the first person to have done a hard reset at the wrong time :) – Lasse V. Karlsen Dec 08 '18 at 19:07
  • @LasseVågsætherKarlsen Ok, yes I agree. Thank you again for help. I know if may sound different but now I have also voted to close this question. – pjj Dec 08 '18 at 19:10

0 Answers0