【问题标题】:git: how to review changes done in branchgit:如何查看分支中所做的更改
【发布时间】:2014-12-11 08:15:35
【问题描述】:

考虑以下情况:

多个分支 - master、dev1..dev-n 和 feature1。在 feature1 分支上发生了一些开发(提交到该分支),我需要对其进行审查。

不过……

  1. Feature1 分支在过去的某个时间点从主分支中分离出来。
  2. 在合并到master之前,master已经合并到Feature1分支
  3. Feature1(+master) 被合并回 master。

所以图表看起来像这样:

M F
|
g  (merge F to master)
|\
| \
f |
| 4 (last commit to F)
e |
| 3 (merge master to F - F contains commit b,c)
d/|
| 2
c |
| 1 (first commit to F)
b /
|/
a(base)

我如何看到直接提交到分支 F (1-4) 而没有看到提交到其他分支并合并到 F (a-g) 中?

【问题讨论】:

    标签: git merge git-merge


    【解决方案1】:

    你可以试试这个:git log d..4

    表示4 (a b c d 1 2 3 4) 中的所有提交,而不是d (a b c d) 中的所有提交,结果为1 2 3 4

    有关Revision Selection的更多信息,请访问Revision Selection

    【讨论】:

    • 如何识别 4 和 d?如果从 master 到分支还有其他合并怎么办 - 例如e->3.5(在 3 和 4 之间)?
    【解决方案2】:

    这是使用 reflog 的定制解决方案:

    git log --first-parent --no-merges $(git reflog feature1|tail -1|cut -d' ' -f1)..feature1
    

    reflog 给出了该分支引用的所有更新,tail 只获取第一个(即 fork 点),然后我们只是削减了 fork 点的 SHA。

    【讨论】:

    • reflog 对我没有帮助,因为更改是由其他团队成员在他们的机器上完成的。我没有他们的 reflog 告诉我发生了什么。
    猜你喜欢
    • 2012-02-03
    • 2016-03-07
    • 2021-08-05
    • 2011-09-29
    • 2018-11-02
    • 1970-01-01
    • 2018-06-07
    相关资源
    最近更新 更多