我使用 this blogpost 中描述的 git 工作流程. 简而言之:每个人都在他/她自己的分支内开发,在 merge 回 master 之前,你将你的分支重新设置为 master 以获得干净的历史。
这有效。
现在我们有了一个子模块,因为这是一个内部插件 (Rails),我们需要经常更改它。所以大多数时候我在通用分支和子模块分支中都有更改。
在上述工作流中使用子模块的最佳方式是什么。
我首先尝试将更改推送到子模块(git checkout master、git pull、git checkout branch、git rebase master、git checkout master、git merge branch)。
然后,当我尝试为我的根做同样的事情时,我的插件(子模块)总是出错。在执行 git rebase --continue
之前,我必须先解决错误.所以如果尝试 git mergetool
我将我的文件夹转换为文件。
rebase 结束后,我只是恢复了 <folder_name>.orig
覆盖文件 <folder_name>
一切都很好。
但不知何故感觉应该有更好的方法。
简而言之:当通过 checkout-b/rebase/merge - workflow 工作时,您如何同时处理更改的子模块?
最佳答案
无论您遵循什么工作流程with submodules , 有一个规则你不应该忘记:
(来自 Git 教程)
If you want to make a change within a submodule, you should first check out a branch, make your changes, publish the change within the submodule, and then update the superproject to reference the new commit.
$ git checkout master
$ echo "adding a line again" >> a.txt
$ git commit -a -m "Updated the submodule from within the superproject."
$ git push
$ cd ..
$ git add a # There is a gotcha here. Read about it below.
$ git commit -m "Updated submodule a."
那么在尝试从所述父项目进行 rebase /merge 之前,您是否在父项目中提交了子模块的新状态?
关于ruby-on-rails - git:在使用子模块时如何将更改很好地返回到 master,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3117517/