Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97400

Git commit recovery after packed-refs deletion and hard reset

$
0
0

is it possible to recover commit after deleting corrupted packed-refs and hard reset? Let me explain my scenario in as much detail as possible.

Week 1: I have worked on particular code. After completing the code, I have done below git commands,

  • git add .
  • git commit -m "commit_text" --no-verify
  • git push origin --no-verify (I am not 100% sure but my git bash showing this in last commands which I am checking through up-arrow and I have not find my commit or push on github)

Week 2 (yesterday): My system crashed while working on other code section. And after system restart I started getting error in my local branch in VSC and git bash Error: unterminated line in .git/packed-refs

As Usual I googled and performed below steps and git commands:

  1. deleted packed-refs(shift-delete - cannot recover)
  2. git gc --auto
  3. git init
  4. git reset --hard
  5. git init (again)
  6. git remote add remote_address
  7. git pull dev(dev branch is where all developers merge their code)
  8. git fetch (in VSC terminal as it was not connecting to remote branch)

After these steps everything started working fine. But I never checked the week 1 changes that if it is present or not.

Now today I pushed my code(I have pushed using git push -f --no-verify as some issue was there while using git push --no-verify, which i dont remember)Now in evening I am not able to find my week-1 code changes. I have tried below git commands to recover as no commit or push is present on GITHUB, but of no use till now.

  1. git reflog show (but only showed today's commits)
  2. git fsck --lost-found (created lost-found directory but didnt found my changes, although very old changes are present :(
  3. checked dangling commits (no luck)
  4. git log --all -g --diff-filter=D --stat (nothing happened - used this link's suggestion)

Please if any one can suggest any thing else to recover my commits and changes. I have commit texts but no commit-id or SHA1 of commit. Please help!!


Viewing all articles
Browse latest Browse all 97400

Trending Articles