0

I've hard reset to a particular commit. After do that my changes are gone. Can I get back my changes in git?

I'd following steps.

git reset --hard [commit id]
git push origin [branch name] --force
3
  • 4
    Unstaged changes are lost. To retrieve committed changes, try git reflog Commented Apr 20, 2018 at 16:00
  • I'd that. But I can't see anything.
    – Vasi
    Commented Apr 20, 2018 at 16:01
  • Thanks @WilliamPursell it's working like a charm. Sorry first I wrongly saw.
    – Vasi
    Commented Apr 20, 2018 at 16:09

1 Answer 1

2

enter image description here As @William mentioned, reflog should do the trick Look at the image above of git reflog. I followed the following steps:

  1. First commit
  2. second commit
  3. Hard reset to first commit
  4. Force push the changes.
  5. Next, git reset 83a0402 which is the sha for the second commit.

You should be able to see your changes now

Not the answer you're looking for? Browse other questions tagged or ask your own question.