Git 分支/变基良好实践
我有以下场景:
3 个分支:
- 大师
- MyBranch 从 Master 中分支出来,目的是开发系统的新功能
- MyBranchLocal 从 MyBranch 中分支出来,因为我的分支
MyBranch 的本地副本正在被其他开发人员(正在开发与我相同的功能)重新基础并推送。
作为 MyBranch 分支的所有者,我希望通过变基使其与 Master 保持同步。我还需要将对 MyBranchLocal 所做的更改与 MyBranch 合并。
有什么好的方法可以做到这一点?
到目前为止我尝试过的几种可能的情况:
I.
1. 将更改提交到 MyBranchLocal
2. 针对 Master 重新设置 MyBranch
3. 根据 MyBranch 重新设置 MyBranchLocal 的基础
4. 将 MyBranch 与 MyBranchLocal
II 合并。
1. 将更改提交到 MyBranchLocal
2. 将 MyBranch 与 MyBranchLocal 合并
3. 针对 Master 重新设置 MyBranch
4. 根据 MyBranch
III 重新设置 MyBranchLocal 的基础。
1. 将更改提交到 MyBranchLocal
2. 针对 Master 重新设置 MyBranch
3. 将 MyBranch 与 MyBranchLocal 合并
4. 针对 MyBranch 重新调整 MyBranchLocal
我已经知道场景 III 似乎会严重扰乱提交历史记录,可能会重复提交。
你的经验是什么?您建议使用哪些方案来最大程度地减少合并工作并保持历史记录干净?
I have a following scenario:
3 branches:
- Master
- MyBranch branched off Master for the purpose of developing a new feature of the system
- MyBranchLocal branched off MyBranch as my local copy of the branch
MyBranch is being rebased against and pushed to by other developers (who are working on the same feature as I am).
As the owner of the MyBranch branch I want to keep it in sync with Master by rebasing. I also need to merge the changes I make to MyBranchLocal with MyBranch.
What is a good way to do that?
Couple of possible scenarios I tried so far:
I.
1. Commit change to MyBranchLocal
2. Rebase MyBranch against Master
3. Rebase MyBranchLocal against MyBranch
4. Merge MyBranch with MyBranchLocal
II.
1. Commit change to MyBranchLocal
2. Merge MyBranch with MyBranchLocal
3. Rebase MyBranch against Master
4. Rebase MyBranchLocal against MyBranch
III.
1. Commit change to MyBranchLocal
2. Rebase MyBranch against Master
3. Merge MyBranch with MyBranchLocal
4. Rebase MyBranchLocal against MyBranch
I already know that scenario III seems to be messing the commit history up a lot, potentially duplicating commits.
What is your experience? What scenarios do you recommend to minimize the merging effort and keep the history clean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我个人的建议。这个专注于拥有直接的提交历史记录,并在“更具体”的分支上失败(你最好搞乱本地分支而不是功能分支)。
My personal suggestion. This one is focused on having a straight commit history, and failing on the "more specific" branches (you'd better mess up your local branch than the feature branch).
我在链接到Linus电子邮件后发现了这个问题。根据电子邮件 - 在某些公共网站上发布历史记录后,您不应该重新设置基准,因为您可能会破坏其他人的历史记录。因此,对 MyBranchLocal 进行变基是可以的,但对 MyBranch(与其他开发人员共享)则不行。
I found this question after link to Linus email. According to email - you shouldn't rebase after you published your history in some public site, because you could destroy other people history. So, rebase for MyBranchLocal is OK, but for MyBranch (shared with other developers) is not.