简体   繁体   English

撤消错误的github存储库中的pull

[英]undoing a pull from the wrong github repository

I just did a pull from github and pulled from the wrong github repository into my project. 我刚刚从github做了一个拉动,从错误的github存储库拉到我的项目中。 How do I undo this? 我该如何撤消这个?

Thanks! 谢谢!

One way to do this 一种方法来做到这一点

$ git reset --hard latest-good-commit-hash

Use git log --all (or more graphically, use gitk --all ) to see the commit history 使用git log --all (或更多图形,使用gitk --all )查看提交历史记录

Try git reflog . 试试git reflog Reflog allows you to undo almost any operation. Reflog允许您撤消几乎任何操作。 Something like this 像这样的东西

git reset --hard HEAD@{1}

However, if you had dirty working copy, it will erase all your changes, so beware. 但是,如果您有脏工作副本,它将删除您的所有更改,所以要小心。

git reset --hard HEAD^

This command resets your branch to the previous commit, that is the commit before the merge commit, which is the one you want to undo. 此命令将您的分支重置为先前的提交,即合并提交之前的提交,即您要撤消的提交。 Your work will be left untouched. 你的工作将保持不变。

Remember that everything that has been commited is still there as loose objects and you can always use git reflog to revert to any version HEAD has pointed to before. 请记住,已提交的所有内容仍然是松散的对象,您始终可以使用git reflog恢复到HEAD之前指向的任何版本。 This is why it's so important to commit often with git, you can undo all changes you have done with ease. 这就是为什么经常使用git提交这么重要的原因,你可以轻松撤消所做的所有更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM