简体   繁体   English

如何从主分支撤消 git pull

[英]How to undo git pull from master branch

I wanted to make my branch up to date and mistakenly pulled from master branch using " git pull origin master " and now i have some 700 pending changes to commit.我想让我的分支保持最新,并使用“git pull origin master”错误地从主分支中拉出,现在我有大约 700 个待提交的更改要提交。 How do i undo this and not mess up anything in here?我如何撤消这个并且不在这里搞砸任何东西?

Thanks!谢谢!

To undo the merge, you could use git reset --hard .要撤消合并,您可以使用git reset --hard This will reset the local repository to a previous state.这会将本地存储库重置为以前的状态。

Be aware though that this will remove all uncommitted changes, potentially leading to a loss of work:请注意,这将删除所有未提交的更改,可能会导致工作丢失:

Alternatively, you can reset to a particular point in time, such as:或者,您可以重置到特定时间点,例如:

git reset --hard master@{"10 minutes ago"}

I used git stash and that took me back to the clean working directory.我使用了git stash ,这让我回到了干净的工作目录。 Thank you for all your responses!感谢您的所有回复!

git reset --hard master@{"[time]"}

and be sure to replace time since the last pull for detailed answer check this并确保更换自上次拉动以来的时间以获取详细答案检查此

Undo git pull, how to bring repos to old state 撤消 git pull,如何将 repos 恢复到旧状态

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

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