Home > Back-end >  Can we recover deleted commits with rm -rf?
Can we recover deleted commits with rm -rf?

Time:09-26

I made a mistake I ran these commands then my projects become empty. Is there a way I can restore a very important one?

rm -rf .git
git init
git add.
git commit -m "Initial commit"
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git
git push -u --force origin master

I did find a backup but all of the files contains null null values:

CodePudding user response:

also i did backup with a software i found all the file but all of them contains null null value enter image description here

CodePudding user response:

git push -u --force origin master

after that you need to consult git reflog. All commits on the remote are still present, and you can see it with git reflog. you will have to reset your master to the commitHASH that was before you ran --force.

also have a look at : git can I view the reflog of a remote?

As mentioned above garbage collection may take place, then things will get lost

  •  Tags:  
  • git
  • Related