简体   繁体   English

使用git desktop我提交了更改并按下了同步。 发生合并错误,我的本地文件发生了很大变化。 如何撤消更改?

[英]Using git desktop I committed my changes and pressed sync. There were merge errors and my local files got changed a lot. How to undo changes?

当我不应该同步并更改许多本地文件时,我不小心进行了同步,如何撤消此同步?

The following answer assumes that a) you committed all your valuable work already, and b) you don't want anything which came in from the recent merge ("sync"), from the remote branch. 以下答案假定a)您已经完成了所有有价值的工作,b)您不希望从远程分支的最近合并(“ sync”)中得到任何东西。 Assuming both of these are true, you can just do a hard reset to the current HEAD of your branch: 假设这两个都是正确的,则只需将硬重置为分支的当前HEAD:

git reset --hard HEAD

In case you ever end up in a similar situation where you don't want to nuke your entire working directory (and maybe stage as well, if you've staged anything), you can use the following command to checkout an individual file from the HEAD: 如果你曾经结束了在类似的情况下,你想要核弹攻击你的整个工作目录(也许阶段为好,如果你上演的任何东西),你可以使用下面的命令来签从一个单独的文件头:

git checkout -- path/to/some/file.ext

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

相关问题 如何撤消对Git中某些跟踪文件的已提交和推送的更改? - How do I undo my committed and pushed changes to some of the tracking files in Git? 如何撤消对Git所做的更改? - How do I undo committed changes on Git? 提交我的更改而不是 git 合并 -- 继续 - Committed my changes instead of git merge --continue 我如何查看git登录,以便将更改到达我的计算机而不是提交时的顺序? - How do I see git log in the order the changes arrived at my machine not when they were committed? 在 Git 合并冲突之后,很多我没有接触到的文件变成了要提交的更改 - After a Git merge conflict, a lot of files I didn't touch become changes to be committed 当我将本地更改提交到新分支,推送该分支,然后切换分支并切换回来时,我所有的文件更改都丢失了 - when I committed my local changes to a new branch, pushed that branch, then switched branches, and switched back, all my file changes were lost git - 如何撤消对本地提交文件的更改 - git - How to undo changes to a locally committed file Git和TortoiseSVN,我如何撤消本地存储库中的更改,而无需再次克隆远程仓库 - Git and TortoiseSVN, how do i undo my changes in local repository without cloning the remote repo again 如何合并我的git变化? - How to merge my git changes? 如何撤消git中的本地更改 - How to undo local changes in git
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM