简体   繁体   English

GIT合并和rebase工作流程确认?

[英]GIT merge and rebase workflow confirmation?

I have read a few others' questions regarding merge VS rebase, what to use and when, but I still have some questions for regular GIT users. 我已经阅读了其他几个关于合并VS rebase,使用什么以及何时使用的问题,但我仍然对常规GIT用户有一些问题。 Firstly, let me post what I understand to be good GIT practice: 首先,让我发布我理解为优秀的GIT实践:

  1. Create new branch B from existing branch A 从现有分支A创建新分支B.
  2. Add/commit changes on branch B 在分支B上添加/提交更改
  3. Rebase updates from branch A 来自分支A的重新更新
  4. Merge changes from branch B onto branch A" 将分支B的更改合并到分支A“

From what I understand so far, the workflow above works best when using a heirarchical branching model (ie A = master branch, and B = experimental branch for working on a new feature). 从我到目前为止的理解,上面的工作流程在使用分层分支模型时效果最好(即A =主分支,B =实验分支用于处理新特征)。 In short, it's good to rebase down the tree, and merge back up to the master. 简而言之,最好重新树下树,然后合并回主人。 Am I correct in thinking this? 我在想这个是正确的吗?

Now, if working with other developers who might be committing/merging changes to A (master branch), I would assume it's best for me to repeat steps 2 and 3 as often as I like to ensure that my work on branch B does not conflict with anything other users have been committing to branch A. If there are any conflicts, using rebase on branch 2 would reapply my commits and allow me to work out these conflicts BEFORE merging back up to branch A. Am I correct in my understanding? 现在,如果与其他可能正在提交/合并A(主分支)的开发人员合作,我认为我最好经常重复步骤2和3,以确保我在分支B上的工作不冲突任何其他用户一直致力于分支A。如果有任何冲突,使用分支2上的rebase将重新应用我的提交并允许我在合并回到分支A之前解决这些冲突。我的理解是否正确?

Lastly, here's my main question: If I am not working with any other developers, and I am not touching branch A until I've finished my new feature in branch B, can I then skip the rebase (step 3), and just merge branch B into the master branch A? 最后,这是我的主要问题:如果我不与任何其他开发人员合作,并且我在分支B中完成新功能之前我没有触及分支A,那么我可以跳过rebase(步骤3),然后合并分支B进入主分支A? I guess it still doesn't hurt to do a rebase first, but unnecessary if I know that branch A hasn't been touched since creating branch B. Am I correct in my understanding? 我想首先做一个rebase仍然没有坏处,但是如果我知道自从创建分支B之后没有触及分支A,那就没有必要了。我的理解是否正确?

PS. PS。 I'd like to thank you guys in advance for any guidance you can give me! 我想提前感谢你们给我的任何指导! I'm new to GIT, and never used a SCM system before using GIT. 我是GIT的新手,在使用GIT之前从未使用过SCM系统。

Thank you, Jesse Leite http://www.aurorafxstudios.com/ 谢谢你,Jesse Leite http://www.aurorafxstudios.com/

No it's not a good idea to over-use rebase. 不,过度使用rebase不是一个好主意。 I started out that way but have done nothing but merges and resets. 我这样开始但除了合并和重置之外什么也没做。 Take a look at my workflow . 看看我的工作流程 It is based on nvie's . 它基于nvie的

In short, you want to be organized with your work. 简而言之,您希望按照您的工作进行组织。 Making branch A the basis for branch B ties them together. 使分支A成为分支B的基础。 This can be a bad thing if something in A is bad, it may not be trivial to "undo" it. 如果A中的某些内容不好,这可能是一件坏事,“撤消”它可能并不容易。

Your understanding is sound. 你的理解是合理的。 If nothing's touched A, then your rebase would be a no-op. 如果没有任何东西触及A,那么你的rebase将是一个无操作。 The nice thing with A not changing is that you know there'll be no conflicts! A不变的好处是你知道不会有冲突!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM