1

I had some local modification into multiple files which i do not want to submit So i have done following setps but my committed changes has gone can anyone plz

  1. commit file which need to retain code changes

  2. during push code got error you are behind the origin

  3. I have overwrite local changes with following link Force overwrite of local file with what's in origin repo?

  4. right now my commited changes has gone any help.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
user765443
  • 1,856
  • 7
  • 31
  • 56
  • You completely overwrote the remote branch with your local branch. – dan1st Sep 24 '21 at 11:57
  • At the very least, your local changes should have gone in a separate branch. However, this points out the issue of trying to use your Git working directory for actually running your code. You should *deploy* your code properly before running it. – chepner Sep 24 '21 at 12:00
  • No commit is ever overwritten in git. Your branch stopped referencing a commit to reference another, that's all. It's still in your repo's objects. See Antonio's answer. – Romain Valeri Sep 24 '21 at 12:07

1 Answers1

2

If did not GC run, you can try with this:

# Inspect ref log to find lost commit

git reflog

# Retrieve the lost commit

git cherry-pick <lost-commit-hash>

Let me know if it worked.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74