git:在使用子模块时如何将变化很好地转换回主模式 [英] git: how to get changes nicely back into master when working with submodules

查看:81
本文介绍了git:在使用子模块时如何将变化很好地转换回主模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这篇博文
简而言之:每个人都在他/她自己的分支中开发,在合并回主人之前,您将重新分配您的分支以再次掌握以获得清晰的历史记录。



工程。

现在我们有一个子模块,因为这是一个内部插件(Rails),我们需要经常更改它。所以大多数时候我在普通分支和子模块分支都进行了修改。



在工作流程中使用子模块的最佳方式如上所述。 / p>

我首先尝试将我的更改推送到子模块(git checkout master,git pull,git checkout分支,git rebase master,git checkout master,git merge branch) / p>

然后,当我尝试为我的根执行相同操作时,我总是在我的插件(子模块)上出现错误。我必须在执行 git rebase --continue 之前解决错误。因此,如果尝试 git mergetool 我将我的文件夹转换为文件。



在rebase结束后,我只是恢复< folder_name> .orig 以覆盖文件< folder_name> ,一切正常。



但不知何故,它觉得应该有更好的方法。



简而言之:通过checkout -b / rebase /合并 - 工作流程,您如何同时处理更改后的子模块? 无论您遵循的工作流程是什么与子模块,有一条规则,你不应该忘记:

(从Git教程)


如果您想在子模块内进行更改,您应该首先检查分支,进行更改,发布更改子模块,然后然后更新超级项目以引用新提交




  $ git checkout master 
$ echo再次添加一行>> a.txt
$ git commit -a -m更新了超级项目中的子模块。
$ git push
$ cd ..
$ git add a#这里有一个问题。请阅读下面的内容。
$ git commit -m更新子模块a。

在你尝试你的rebase / merge之前,你在父项目中提交了你的子模块的新状态说父项目?

i use the git workflow as described in this blogpost. In short: everybody develops inside his/her own branch, before merging back to master, you rebase your branch to master again to get clean history.

This works.

Now we have a submodule, and because this is an in-house plugin (Rails), we need to change this often. So most of the times i have changes both in the general branch and in the submodule branch.

What is the best way to work with submodules in the workflow as above.

I first try to push my changes to the submodule (git checkout master, git pull, git checkout branch, git rebase master, git checkout master, git merge branch).

Then, when i try to do the same for my root, i always get an error on my plugin (submodule). I have to resolve the error, before doing git rebase --continue. So if try to git mergetool i converts my folder to a file.

After the rebase has ended, i just restore the <folder_name>.orig to overwrite the file <folder_name> and all is well.

But somehow it feels there should be a better way.

In short: when working via checkout-b/rebase/merge - workflow, how do you handle the changed submodules simultaneously?

解决方案

Whatever workflow you are following with submodules, there is one rule you shouldn't forget:
(From the Git tutorial)

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."

So did you commit the new state of your submodule within the parent project before attempting your rebase/merge from said parent project?

这篇关于git:在使用子模块时如何将变化很好地转换回主模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆