Git - 如何隐藏冲突并稍后解决

Git - how to stash away a conflict and resolve it later

我将一个 b运行ch 合并到另一个 运行 并发生冲突。我部分解决了,但我需要同事的帮助才能完成解决。与此同时,在我等待他的时候,我想把这个矛盾藏起来,继续做其他事情。但我不想在我已经解决的问题上失去进展。

我该怎么办?除了在另一个目录中再次克隆 repo 或手动复制有冲突的文件然后再将其复制回来之外,有没有办法完成此操作?

如果我想简单地把它藏起来,git 会这样抱怨:

path/to/file/with/unresolved/conflict: needs merge
path/to/file/with/unresolved/conflict: needs merge
path/to/file/with/unresolved/conflict: unmerged (somesha)
path/to/file/with/unresolved/conflict: unmerged (somesha)
path/to/file/with/unresolved/conflict: unmerged (somesha)
fatal: git-write-tree: error building trees
Cannot save the current index state

在您的存储库中启用 rerere

$ git config rerere.enabled true

尽可能解决所有冲突,然后中止合并操作 (git merge --abort)。 rerere 将注册所有成功的冲突解决方案,并在以后自动重播相同的冲突。

查看此博客条目:https://git-scm.com/blog/2010/03/08/rerere.html