硬重置Git存储库后,回滚到未被更改的更改 [英] Rollback to uncommited changes after hard reset a Git Repository

查看:112
本文介绍了硬重置Git存储库后,回滚到未被更改的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误地,我很难重置我的git仓库。通过这样做,我所做的所有改变都没有了。现在,我想要将Git回滚到所有未提交的更改。请帮我解决一下这个。

解决方案

未提交的更改表示 local 回购(即使您在amazon ec2上有远程回购)



这意味着您必须已经将( git add )文件添加到本地克隆中,然后执行 git reset --hard



如果是这种情况,您仍然可以使用 rel =nofollow noreferrer> git fsck ,如恢复已添加到索引但通过 git reset 删除的文件:


  • 首先,对当前的回购进行完整备份

  • 然后尝试 git fsck --full --unreachable --no-reflog


Mistakenly, i hard reset my git repository. By doing this all the changes that i have made has been gone. Now, i want to rollback Git to all the uncommitted changes. Please help me with this.

解决方案

"uncommitted changes" means local repo (even though you have a remote repo on amazon ec2)

That means you must have added (git add) files to a local clone, then do a git reset --hard.

If that is the case, you can still find those added files with a git fsck, as described in Recover files that were added to the index but then removed by a git reset:

  • first, do a full backup of your current repo
  • then try a git fsck --full --unreachable --no-reflog

这篇关于硬重置Git存储库后,回滚到未被更改的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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