在 merge.renameLimit 警告加上冲突后撤消 git merge

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10737966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:57:32  来源:igfitidea点击:

undoing git merge after merge.renameLimit warning plus conflicts

gitversion-controlgit-merge

提问by Stefano Borini

I am trying to do a merge squash from a devel branch into the master.

我正在尝试从开发分支到主分支进行合并壁球。

stefanos-imac:trunk borini$ git merge --squash devel
CONFLICT (content): Merge conflict in test1
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 2224 and retry the command.
Squash commit -- not updating HEAD
Automatic merge failed; fix conflicts and then commit the result.

fair enough.

很公平。

stefanos-imac:trunk borini$ git config merge.renameLimit 999999

Then I try to undo the merge and redo it with the higher limit

然后我尝试撤消合并并使用更高的限制重做

stefanos-imac:trunk borini$ git merge --abort
fatal: There is no merge to abort (MERGE_HEAD missing).

Ok, so maybe I have to do as it says and just reinvoke the merge command

好的,所以也许我必须按照它说的去做,然后重新调用合并命令

stefanos-imac:trunk borini$ git merge --squash devel
fatal: 'merge' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.

oh git, why are you such a git?

哦,混蛋,你怎么这么混蛋?

More to the point, does anyone know how to get out of this situation ?

更重要的是,有谁知道如何摆脱这种情况?

回答by holygeek

Em, git reset --hard origin/master?

嗯,git reset --hard origin/master

回答by Martin G

The modern way to undo a merge is (but this only works when MERGE_HEAD is present):

撤消合并的现代方法是(但这仅在存在 MERGE_HEAD 时才有效):

git merge --abort

And the slightly older way, which will work in this case (MERGE_HEAD is missing):

而稍微旧的方式,在这种情况下会起作用(缺少 MERGE_HEAD):

git reset --merge

The old-school way described in accepted answer (warning: will discard all your local changes):

接受的答案中描述的老派方式(警告:将丢弃所有本地更改):

git reset --hard

So notice that git merge --abortis only equivalent to git reset --mergegiven that MERGE_HEADis present. This can be read in the git help for merge command.

所以请注意 thatgit merge --abort只等价于git reset --mergegiven that MERGE_HEADis present。这可以在合并命令的 git 帮助中阅读。

git merge --abort is equivalent to git reset --merge when MERGE_HEAD is present.

After a failed merge, when there is no MERGE_HEAD, the failed merge can be undone with git reset --mergebut not necessarily with git merge --abort.

合并失败后,如果没有MERGE_HEAD,失败的合并可以用 撤消,git reset --merge但不一定用git merge --abort

回答by PeloNZ

git merge --abortwill also do the trick. A bit quicker than typing the full git reset command.

git merge --abort也能解决问题。比输入完整的 git reset 命令快一点。

Abort also works with rebaseand cherry-pick.

Abort 也适用于rebasecherry-pick