如何获取版本树中两个提交之间的所有提交?

时间:2011-12-28 03:08:30

标签: git revision

鉴于有一棵树如下所示:

        d1a--d1b---d1c--d1d--d1e     <dev>
       /                /      \
a--b--c---d---e--------f---g----h--i <master>

a是最早的提交,而i是最新提交, HEAD d1a已从分支到新分支 dev ,添加了一些新的更改并合并了来自的更改(来自{{1转到f),然后最终合并回d1d的'master'。

在执行git log / rev-list时,如何选择:

  1. 从HEAD到e的所有提交:  i,h,g,f,e,d1e,d1d
  2. 从HEAD到g的所有提交:  我,h,g
  3. 从HEAD到d1b的所有提交:  i,h,g,f,d1e,d1d,d1c,d1b
  4. 非常感谢任何提示/建议/提示!

1 个答案:

答案 0 :(得分:-1)

来自man git-rev-parse

SPECIFYING RANGES
   History traversing commands such as git log operate on a set of commits, not just a single commit. To these
   commands, specifying a single revision with the notation described in the previous section means the set of commits
   reachable from that commit, following the commit ancestry chain.

   To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable from r2
   but exclude the ones reachable from r1.

   This set operation appears so often that there is a shorthand for it. When you have two commits r1 and r2 (named
   according to the syntax explained in SPECIFYING REVISIONS above), you can ask for commits that are reachable from r2
   excluding those that are reachable from r1 by ^r1 r2 and it can be written as r1..r2.

   A similar notation r1...r2 is called symmetric difference of r1 and r2 and is defined as r1 r2 --not $(git
   merge-base --all r1 r2). It is the set of commits that are reachable from either one of r1 or r2 but not from both.

   Two other shorthands for naming a set that is formed by a commit and its parent commits exist. The r1^@ notation
   means all parents of r1. r1^! includes commit r1 but excludes all of its parents.

甚至有一个例子,所以我是RTFM; - )