How to restore the project if I have only .git folder?

后端 未结 1 1995
长情又很酷
长情又很酷 2020-12-11 04:52

How to restore my project? I save only /.git folder and now need to restore project from this folder.

相关标签:
1条回答
  • 2020-12-11 05:25

    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.

    0 讨论(0)
提交回复
热议问题