从被拆分为子模块的远程设备中拉出和重新绑定 [英] Pull and rebase from a remote that's been split into submodules

查看:169
本文介绍了从被拆分为子模块的远程设备中拉出和重新绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在合作一个GitHub项目(我已经分叉回购),最近被重新构建为子模块



之前我会 git stash 我的更改,做一个 git pull --rebase shared_origin master ,然后执行 git stash pop 继续工作。在对我的本地仓库进行更改后,我会使用 git push my_origin development 将它们推送到共享仓库的分支,然后创建一个 PR < code $。

现在项目已经拆分成子模块,我该如何执行复制整个回购(包括所有子模块)应用我的(未合并)更改并继续我的开发?



请考虑将我已更改的文件已被更改为不同目录的可能性部分子模块重组。

解决方案

您可以考虑选项 pull --recurse-submodule = yes

不要忘记你可以隐藏和重新绑定git pull。

  git config pull.rebase true 
git config rebase.autoStash true

其实,结合

  git config fetch.recurseSubmodules true 

现在,一个简单的 git pull 一个引用所有这些子模块)就足够了。

注意:子模块默认位于分离HEAD模式,所以要确保他们已经先签出了一个分支,并且你已经在其中进行了一些本地提交,如果你想让rebase在这些子模块中实际执行某些操作。

I'm collaborating on a GitHub project (I've forked the repo) that has recently been re-structured into submodules.

Earlier I would git stash my changes, do a git pull --rebase shared_origin master, and then perform git stash pop to continue working. After commiting changes to my local repo, I would push them to my fork of the shared repo using git push my_origin development and then create a PR.

Now that the project has been split into submodules, how do I perform a pull rebase that replicates entire repo (including all submodules), re-apply my (unmerged) changes and continue with my development?

Please do consider the possibility where the file(s) I had changed have been moved to a different directory as a part of submodule-restructuring.

解决方案

You could consider the option pull --recurse-submodule=yes.

And don't forget you can stash and rebase by default on a git pull.

git config pull.rebase true
git config rebase.autoStash true

Actually, combine that with the config:

git config fetch.recurseSubmodules true

And now, a simple git pull from the parent repo (the one referencing all those submodules) is enough.

Note: submodules are by default in detached HEAD mode, so make sure they have checked out a branch first, and you have done some commits locally in them, if you want the rebase to actually do something in said submodules.

这篇关于从被拆分为子模块的远程设备中拉出和重新绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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