git - 使用子模块将 git 分支合并到我的正确方法
问题描述
这一定是个骗子,但我找不到能找到答案的搜索词组。
我有一个foo
带有一个子模块的 git repo (),指向abc123
另一个 repo ( bar
) 的提交。
我有一个长期存在的分支,foo
仍然指向 commit abc123
。
更改发生在foo
的main
分支上,包括对子模块的更新,将其移至 commit zyx987
。
现在我想合并main
到我的分支中。
通常我会这样做git merge main
。使用子模块,这向我展示了:
# On branch feature
# All conflicts fixed but you are still merging.
# (use "git commit" to conclude merge)
#
# Changes to be committed:
#
# ...
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: bar (new commits)
#
当我导航到bar
目录并执行 agit status
时,我看到它仍在上一次提交 ( abc123
) 中。我试过git add bar
了,但它一直保持在abc123
.
我发现获得新提交的唯一方法是导航到子模块的目录并手动发出git checkout zyx987
.
这里显然有可能出现错误,我很容易错过子模块更改的事实,或者当我手动更新它时选择了错误的提交,更不用说这是我作为开发人员从事的额外工作(不相关) 功能分支,不需要关心该子模块中发生了什么。
git merge
当您发现子模块已更改时,有没有办法说“合并并更新子模块”或(更好)在正常之后接受在源分支中选择的提交?
解决方案
推荐阅读
- bioinformatics - 是否有可能找到 fastq 序列所属的基因(STAR)?
- python - 测试副本集上带有 ReadPreference Secondary 的事务上的 MongoDB 错误
- python - 将表从数据库导出到 mdf 文件
- r - 在R中使用enrichGO对TAIR进行富集分析时不映射任何内容
- vue.js - 使用 Nuxt 添加多个加载组件
- javascript - 在 Vue 应用程序中粘贴大型内容时,Quill Editor 会略微向上滚动
- database-design - 数据仓库设计——创建无主键的维度表
- c# - C#裁剪图像梯形/多边形
- flutter - 连接两个 document.data()['field'] 字段
- flutter - 在没有 super.dispose() 的情况下覆盖 dispose() 是否有效?