切换到子模块时 merge Git

标签 git git-submodules git-merge

我们在我们的应用程序中使用 Qooxdoo 框架。现在,它的副本存储在我们的 Git 存储库的根文件夹“qooxdoo”中。我们已决定将其替换为直接指向 GitHub Qooxdoo 存储库的子模块,以便我们将来可以更轻松地 checkout 新版本。

我基于 master 为这些更改创建了分支,称为 qooxdoo-update。完全删除旧文件夹并为 qooxdoo 添加子模块。

git rm -r qooxdoo
git submodule add git://github.com/qooxdoo/qooxdoo.git qooxdoo

到目前为止,这工作得很好。然而,当我想将 master merge 到这个分支以保持更新直到其他开发人员可以再次测试他们的代码时,问题就出现了。

当我还在 qooxdoo-update 分支时,我发出命令:

git merge origin/master

CONFLICT (file/directory): There is a directory with name qooxdoo in origin/master. Adding qooxdoo as qooxdoo~HEAD

然后...

git status
Unmerged paths: (use "git add/rm ..." as appropriate to mark resolution)

   added by us:        qooxdoo

正在运行...

git rm qooxdoo
qooxdoo: needs merge
rm 'qooxdoo'
Unlink of file 'qooxdoo' failed. Should I try again? (y/n)

或者...

git add qooxdoo
error: unable to index file qooxdoo
fatal: updating files failed

所以我不太确定如何解决该冲突以成功完成 merge 。

最佳答案

如果你想回到你的文件/目录的最新版本,执行:

git reset HEAD qooxdoo

应该可以。

关于切换到子模块时 merge Git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13760150/

相关文章:

git - 在 GIT 中推送一个新分支

git - 撤消 git rebase --skip - 在 rebase 期间重新应用提交

Git merge -X theirs 不 merge 所有更改

python - Conda环境不会在git中存储gitlab密码(Mac)

git - 在 Github 中添加 git 标签时触发发布管道

git - 如何在 GitHub 中创建嵌套存储库?

子模块中的 Git 配置 "bad config file line"

git - 在 Visual Studio 中使用 git 子模块的工作流程

git - Tortoise GIT - 显示 merge 后在分支中创建的更改

git - 如何在 rebase 后保留 --no-ff merge