6

请问各位这种情况应该如何拆分代码提交为多个 PR?

 3 years ago
source link: https://www.v2ex.com/t/798431
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

请问各位这种情况应该如何拆分代码提交为多个 PR?

  TripleZ · 2 小时 17 分钟前 · 109 次点击

假设有 ABC 三个需求,这三个需求需要同一个人开发。

此时开发写好了 ABC 的代码,以 A->B->C 的顺序用 Git 提交至个人分支中。

但 review 代码时,三个需求一起 review 过于痛苦,我们希望有更细粒度的方式。

因此可以有两种提 PR 的方式:

从 master 分支拉出三个需求分支,提出三个 PR,目标分支都为 master ,代码提交分别是:

master
  \ \ \
   \ \ -> A (PR1: A..master)
    \ --> B (PR2: B..master)
     ---> C (PR3: C..master)

从 master 分支只拉出一条分支,但是基于该个人分支再拉分支,最后提出三个 PR,但是目标分支各不一样,提交图如下:

master
      \
       -> A (PR1: A..master)
           \
            -> B (PR2: B..A)
                \
                 -> C (PR3: C..B)

请问各位哪种方法更好呢?

个人担忧:方法一可能会在合并时产生 conflict,方法二对合并顺序有依赖。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK