如何从`git stash pop`解决子模块上的git合并冲突

问题描述 投票:10回答:2

我有一个带子模块的git存储库。我需要弹出我之前隐藏的变化。但是,这会导致子模块引用上出现合并冲突。

除了子模块之外,我想保留我对存储的更改。对于大多数代码文件,我可以通过编辑冲突文件来解决冲突,但这似乎不是子模块的选项。

如何解决合并冲突并仍然从存储中提取我的更改?

$ git stash pop
warning: Failed to merge submodule some-submodule (commits don't follow merge-base)
Auto-merging some-code
Auto-merging some-submodule
CONFLICT (submodule): Merge conflict in some-submodule

$ git status
# On branch some-branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   some-code
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   both modified:      some-submodule
git git-stash git-merge-conflict
2个回答
9
投票

正如git status评论所说:git reset HEAD some-submodule

顺便说一句,在你仔细检查了你的树和索引应该如何之后,你可能会想要git stash dropgit stash pop通常会这样做,但是当有冲突时不会这样做。


0
投票

我正在寻找一个更清洁的解决方案,但编辑存储最终变得更简单。因人而异。

git stash show -v > foo
$EDITOR foo
       (remove the fluff you don't want)
git apply < foo

在我的情况下,只需删除“子项目提交”和相关的差异线工作。

© www.soinside.com 2019 - 2024. All rights reserved.