自动化 git 集成分支的合并?
根据 http://gitster.livejournal.com/42247.html,分支可以是:
- “主题”分支=包含与单个功能/错误修复/实验/等相关的所有内聚更改
- “集成”分支=选择/并选择要从中合并更改的主题分支。
我有主题分支 x
、y
和 z
我有客户 A
和 B
> 每个人都想要/支付不同的功能集。
客户A
想要x
和y
。这很简单:
git checkout A
git merge x y
瞧!我有我需要的东西。但是我如何自动化/记录哪些主题应该合并到 A 中?这就是我所做的。在我的配置文件中,我有:
[branch "A"]
remote=.
merge=refs/heads/x
merge=refs/heads/y
现在每次我想更新分支 A 时,我只需:
git checkout A
git pull
它会自动知道要拉取哪些分支。
这是一个好主意还是坏主意?
更具体地说,这就是我在 .git/config 中的内容:
[branch "A.test"]
remote=.
merge=refs/heads/x
merge=refs/heads/y
这样分支 A(即生产分支)就不会意外地拉取任何更改。
According to http://gitster.livejournal.com/42247.html, branches can be either:
- "topic" branch = which contains all cohesive changes related to a single feature/bug-fix/experiment/etc
- "integration" branch = which picks/and chooses which topic branches to merge changes from.
I have topic branches x
, y
, and z
I have customers A
and B
which each want/paid-for a different set of features.
customer A
wants x
and y
. That's easy enough:
git checkout A
git merge x y
and voila! I have what I needed. But how do I automate/record which topics ought to merge into A? This is what I did. In my config file I have:
[branch "A"]
remote=.
merge=refs/heads/x
merge=refs/heads/y
and so now every time I want to update branch A, I simply:
git checkout A
git pull
and it automatically knows which branches to pull.
Is this a good idea and/or bad idea?
More specifically this is what I have in .git/config:
[branch "A.test"]
remote=.
merge=refs/heads/x
merge=refs/heads/y
So that branch A (which is the production branch) never accidentally pulls any changes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可能不想这样做。一旦 x 和 y 合并到 A 中,将来就没有什么可以从它们合并的了。不过,您的工作流程可能需要这样做。查看 git-flow。
You probably don't want to do that. Once x and y are merged into A, you'll have little else to merge from them in the future. Your work flow might need that though. Check out git-flow.