How to restore my project? I save only /.git folder and now need to restore project from this folder.
1. If you previously committed files to git:
First, try to do a git log
. Then you will see the commits. If you see a commit that makes sense, you can do git checkout <HASH>
. Where Hash is the commit hash.
Then check to see if yours files exits.
2. If it is only local changes that you have not committed:
You can do a git status
to see the changes. A git stash
will stash these changes temporarily and a git stash pop
will re-apply the changes.
NOTE: THE FOLLOWING IS A DESTRUCTIVE GIT PROCESS BUYER BEWARE
You can do a git reset --HARD <HASH>
and then a git push -f
to force push the working code up to your repo eliminating your mistaken commit but also eliminating all other commits after the hash.
It is much better to git revert <HASH>
and then a git push
. This will show the reverting process in your git history and preserve all states. git push -f
is not something you should take lightly as it can cause you much pain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With