撤消git拉,如何将回购旧状态 [英] Undo git pull, how to bring repos to old state

查看:93
本文介绍了撤消git拉,如何将回购旧状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以恢复或撤销git pull,这样我的源/回购将会在执行git pull之前进入旧状态?
我想这样做是因为它合并了一些我不想这样做的文件,但只合并了其他剩余的文件。所以,我想让这些文件回来,这可能吗?
谢谢:)

编辑我想撤销git merge来澄清。
看到一些答案后,我做了这个

  git reflog 
bb3139b ... HEAD @ {0 }:pull:快进
01b34fa ... HEAD @ {1}:clone:from ... name ...

现在,我该怎么办?做 git reset --hard 可以吗?我不想再拧它,所以要求详细的步骤?

解决方案> git pull 会做两件事:它做一个 git fetch 然后一个 git merge 它将合并了已经设置好的分支合并到你的配置中。



所以你想要做的就是撤销合并(撤消抓取并没有什么意义,也不需要)。

要做到这一点,您可以尝试使用 git reset --hard 来重置为之前的状态。使用 git-reflog 命令查找然后重置为它。

警告: git reset --hard code>删除所有未提交的更改。

Is there any way to revert or undo git pull so that my source/repos will come to old state that was before doing git pull ? I want to do this because it merged some files which I didn't want to do so, but only merge other remaining files. So, I want to get those files back, is that possible ? Thanks :)

EDIT I want to undo git merge for clarification. After seeing some answers, I did this

git reflog
bb3139b... HEAD@{0}: pull : Fast forward
01b34fa... HEAD@{1}: clone: from ...name...

Now, what should I do ? Doing git reset --hard is OK ? I don't want to screw it again, so asking for detailed steps ?

解决方案

git pull will do two things: it does a git fetch and then a git merge where it merges branches that have been setup to be merged in your config.

So what you want to do is to undo the merge (undoing the fetch doesn't make a lot of sense and shouldn't be necessary).

To do that you can try using git reset --hard to reset to a previous state. Use the git-reflog command to find the SHA-1 of the previous state and then reset to it.

Warning: git reset --hard removes all uncommitted changes.

这篇关于撤消git拉,如何将回购旧状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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