Git workflow and rebase vs merge questions

后端 未结 11 2223
春和景丽
春和景丽 2020-11-22 03:09

I\'ve been using Git now for a couple of months on a project with one other developer. I have several years of experience with SVN, so I guess I bring a lot of baggage to th

11条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 03:56

    In my workflow, I rebase as much as possible (and I try to do it often. Not letting the discrepancies accumulate drastically reduces the amount and the severity of collisions between branches).

    However, even in a mostly rebase-based workflow, there is a place for merges.

    Recall that merge actually creates a node that has two parents. Now consider the following situation: I have two independent feature brances A and B, and now want to develop stuff on feature branch C which depends on both A and B, while A and B are getting reviewed.

    What I do then, is the following:

    1. Create (and checkout) branch C on top of A.
    2. Merge it with B

    Now branch C includes changes from both A and B, and I can continue developing on it. If I do any change to A, then I reconstruct the graph of branches in the following way:

    1. create branch T on the new top of A
    2. merge T with B
    3. rebase C onto T
    4. delete branch T

    This way I can actually maintain arbitrary graphs of branches, but doing something more complex than the situation described above is already too complex, given that there is no automatic tool to do the rebasing when the parent changes.

提交回复
热议问题