如果我只有.git文件夹,如何恢复项目? [英] How to restore the project if I have only .git folder?

查看:412
本文介绍了如果我只有.git文件夹,如何恢复项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何恢复我的项目?我只保存/.git文件夹,现在需要从该文件夹恢复项目。

如果您以前曾提交过文件到git:

首先,尝试执行 git log 。然后你会看到提交。如果您看到有意义的提交,可以执行 git checkout< HASH> 。其中Hash是提交哈希。



然后检查您的文件是否已退出。



2 。如果只是您未提交的本地更改



您可以执行 git status 看到变化。 git stash 会暂时存储这些更改,并且 git stash pop 会重新应用更改。



注意:以下是Git流程的买方注意事项 $ b 您可以执行 git reset --HARD< HASH> ,然后执行 git push -f 来强制推送直到你的repo的工作代码消除你错误的提交,但也消除哈希后的所有其他提交。

对于 git revert< HASH> 然后一个 git push 。这将显示您的git历史中的恢复过程并保留所有状态。 git push -f 并不是你应该轻视的,因为它会给你带来很大的痛苦。


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.

这篇关于如果我只有.git文件夹,如何恢复项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆