使用 Git 将 master 的更改合并到所有分支中?
我使用 git 维护代码的多个工作副本。我的想法是,我可以检查任何分支,构建并运行它,以查看分支的功能 x 如何适应代码的当前状态。
Git 的主分支是主干,其他 git 分支是我想尝试的功能或东西。因此,我的典型用法是使用最新的修复程序更新 master,然后将 master 合并到各个分支中,以便每个分支都保持最新状态。
这个系统对我来说效果很好,除了我必须签出一个分支,合并主分支并冲洗/重复其他分支这一事实。考虑到像 git 这样的版本控制系统,考虑到随着时间的推移我很容易产生大量分支,我看不到这种扩展效果。
我仍然是一个 git 初学者,所以我怀疑 git 已经拥有某种机制,但我可能会丢失。有吗?如果不是,如何对所有分支进行更改,以便它们自己保持最新状态?
I use git to maintain multiple working copies of my code. The idea is that I can check out any branch, build and run it to see how the branch's feature x fits in with the current state of the code.
Git's master branch is the Trunk and the other git branches are features or things I would like to try out. Therefore, my typical usage is updating the master with the latest fixes and then merging master into the individual branches so each of them stays up to date.
This system works well for me, except for the fact that I have to checkout a branch, merge the master and rinse/repeat for the other branches. Given a version control system like git, I don't see this scaling very well given the fact that I'd be prone to spawning a lot of branches over time.
I'm still a git beginner, so I suspect there may be a mechanism of sorts that git already has that I might be missing. Is there one? If not, how does one commit a change to all branches so they stay up to date on their own?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果
那么您可以在 master 更新后将它们重新设置为 master 。如果您使用的是 Unix shell,这个小脚本可能会起作用。它将每个分支重新建立到主分支上。
If
then you could simply rebase them onto master after master has been updated. This little script might work if you're using a Unix shell. It rebases each branch onto master.
一种可能性(我自己没有测试过)是:
您仍然需要访问您的功能存储库并检查变基或合并是否不会由于某些合并冲突而被阻止。
One possibility (not tested myself) would be:
You will still need to get to your feature repo and check if the rebase or merge is not blocked due to some merge conflicts.
下面检查每个分支并进行合并
The following checks out each branch and does the merge