ruby-on-rails - git:在使用子模块时如何将更改很好地返回到 master

标签 ruby-on-rails git

我使用 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/

相关文章:

ruby-on-rails - 无法安装 mysql2 gem ...( Homebrew 软件上的附带内容也是如此)

ruby-on-rails - Rails 5 SQL 注入(inject)

git - 如何从 jenkins 登录到 git bitbucket 存储库

javascript - 移动到 monorepo 后重新设置分支

git - 如何仅在预提交 git 钩子(Hook)中删除更改行上的尾随空格?

ruby-on-rails - rake 分贝 :test:prepare in Rails 3 app fails with file not found

ruby-on-rails - ruby 名称不能为空错误

ruby-on-rails - ruby 命名空间

git - Visual Studio Code 不允许更改 GitHub 用户 - Git :remote: Permission to Org/Rep denied

Git:别名错误:使用 '--' 将路径与修订分开