共享功能分支的 Git 工作流程是否正确?
我正在尝试找出适合这种情况的正确工作流程:
在共享存储库上,我们有这些分支:
-master
-feature
功能分支是一个共享分支,因为许多开发人员都在工作一起开发新功能。他们正在积极地将更改推送到功能分支。
我正在努力避免“冲突地狱”,因为有一天功能最终会合并回master。目前,我看到一些选项:
1)主动将master合并到feature中,并经常这样做。但是,在git中不建议这样做文档,我开始明白为什么。当我尝试这样做时,我似乎一遍又一遍地解决相同的冲突。
2)以某种方式使用变基。我已经阅读过这一点,但看起来它不起作用,因为 feature 分支实际上是共享的。只需要一名开发人员进行 2 次变基,其他开发人员可能会因历史记录不匹配而产生冲突。
3) 将功能分支转变为集成分支,并让开发人员使用自己的独立功能分支并进行变基以保持理智。
4)完全不同的东西?
I am trying to figure out the right workflow for this situation:
On the shared repo, we have these branches:
-master
-feature
The feature branch is a shared branch, since many developers are working on a new feature together. They are actively pushing their changes to the feature branch.
I'm trying to avoid 'conflict hell' for the day that feature finally gets merged back into master. Currently, I see some options:
1) Actively merge master into feature, and do it often. However, this is not recommended in the git docs, and I'm starting to see why. When I try this, I seem to fix the same conflicts over and over again.
2) Use rebase in some way. I've read up on this, but it looks like it wont work since the feature branch is actually shared. All it takes is one developer to do 2 rebases, and other developers could have conflicts from mismatched history.
3) Turn the feature branch into an integration branch, and have the developers use their own independent feature branches with rebasing to keep things sane.
4) Something completely different?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于共享分支,我会选择#3,并将其用作“集成”分支来巩固他们的工作。
开发人员必须使用 rebase 不断地在
feature
之上重放他们的private
分支,然后再将他们的工作合并回feature
,这样他们就可以:private
分支到feature
)变得微不足道(通常是快进)(如上所述在 "
git rebase
与merge< /code>"
答案)
这个想法是,一旦
feature
分支必须合并到master
中,feature< 就不再接受任何贡献/code> (该分支已“冻结”),您可以首先在
master
之上安全地对其进行变基,或者直接将其合并到master
。然后启动一个新的
feature
分支(如果需要,它实际上可以与之前的feature
分支并行启动)For a shared branch, I would go with #3, and use it as an "integration" branch to consolidate their work.
The developers would have to use rebase to constantly replay their
private
branch on top offeature
before merging back their work tofeature
, that way they are:private
branch tofeature
) a trivial one (normally fast-forward)(as described in "
git rebase
vs.merge
" answer)The idea is that, once
feature
branch has to be merged inmaster
, no more contribution is accepted onfeature
(the branch is "frozen"), and you can safely rebase it on top ofmaster
first, or merge it directly tomaster
.And then you start a new
feature
branch (which can actually start in parallel of the previousfeature
branch if needed)您可以使用
rerere
来处理您的合并冲突都看过好多次了You can use
rerere
to handle the merge conflicts you're seeing multiple times.(我不太热衷于选项 1、2 或 3,所以我正在尝试找到更好的工作流程;因此,我在下面描述我如何考虑解决该问题,希望有人能给我建议)
对于人们来说,将补丁队列重新转变为本地功能分支可能是明智的。
(I'm not too keen on options 1, 2 or 3 so I'm trying to find a better workflow; I'm therefore describing below how I'm thinking of approaching the problem in the hope someone will advise me)
It might be sensible for people to turn the patch queue back into a feature branch locally.
过程如下:-
第一次:
上述命令将从 git 中拉取所有文件
将在我们的本地计算机上创建一个名为 sprint-4 的分支。
将把文件从服务器拉到我们的 sprint-4 分支。
对于每个新功能:-
每日:(在您的功能分支上)
完成当天的工作
git Push origin
功能已完成:
解决冲突(如果有)
分支。
The process is follows:-
First Time:
The above commands will pull all the files from git
Will make a branch with name sprint-4 on our local machine.
Will pull the files from server to our sprint-4 branch.
For every new feature:-
Daily:(on your feature branch)
do your work for the day
git push origin
Feature is complete:
resolve conflicts if any
branch.