我似乎不能让git log --branches正确过滤它的输出。Git似乎忽略了这一点。
例如,git log --graph --all --decorate的头部打印:
* commit 3ae0d17538f787bdde68f37f6644ffe9652d8dc1 (HEAD, feature/branch-ignore)
| Author: Chris Lewis <chris@chris.to>
| Date: Mon Mar 14 17:39:56 2011 -0700
|
| Ignore merge commits, as they're going to be duplicating events
|
* commit 770534e9d77acb03eaf842440c879aec1c5b5500
| Author: Chris Lewis <chris@chris.to>
| Date: Tue Mar 8 14:39:40 2011 -0800
|
| Removed another remote branch check
| 假设我想要按master进行过滤,这应该意味着这些提交被忽略。git log --graph --all --decorate --branches=master的负责人也是:
* commit 3ae0d17538f787bdde68f37f6644ffe9652d8dc1 (HEAD, feature/branch-ignore)
| Author: Chris Lewis <chris@chris.to>
| Date: Mon Mar 14 17:39:56 2011 -0700
|
| Ignore merge commits, as they're going to be duplicating events
|
* commit 770534e9d77acb03eaf842440c879aec1c5b5500
| Author: Chris Lewis <chris@chris.to>
| Date: Tue Mar 8 14:39:40 2011 -0800
|
| Removed another remote branch check
| Git似乎没有过滤。--branches是否与其他参数一起传递似乎没有任何区别。我的Git版本是git version 1.7.4.1。有人知道如何成功地使用这个命令吗?
编辑:我想要做的就是获得一个或另一个分支的日志,而不需要先结帐。
发布于 2015-02-05 08:17:49
首先,(另一个)亚当是对的,使用--all没有意义:如果你只想看到一个分支,就像你的问题所说的那样,为什么要要求所有的分支?
其次,正如在对其他答案的评论中所述,您不需要--branches;只需要使用git log mybranch。
第三,我可以解释为什么git log --branches=mybranch不能工作。git-log(1) man page说:
--branches[=<pattern>]
Pretend as if all the refs in refs/heads are listed on
the command line as <commit>. If <pattern> is given,
limit branches to ones matching given shell glob. If
pattern lacks ?, *, or [, /* at the end is implied.最后一句是这里的关键点。如果<pattern>只是mybranch,那么就没有定位符,所以git-log会将其解释为您输入了
git log --branches=mybranch/*它只匹配$repo/.git/refs/heads/mybranch/*下的引用,即以mybranch/开头的分支。
有一种肮脏的黑客方法可以防止/*被假定:
git log --branches=[m]ybranch但是我想不出任何好的理由来解释为什么你想这样做而不是直接输入
git log mybranch发布于 2011-03-16 03:20:09
因为您指定了--all,所以您将覆盖您所做的任何分支规范。
发布于 2012-07-21 06:29:38
假设你的历史是这样的
d -- e [refs/tags/release1]
/
a -- b -- c [refs/heads/master]
\
f -- g [refs/heads/dev1]
\
h [refs/heads/dev2]如果你使用git log --branches,它是相同的git log master dev1 dev2,所以你会看到提交a,b,c,f,g和h。如果你使用git log release1 --branches=dev*,它和git log release1 dev1 dev2是一样的。您将看到a、d、e、b、f、g和h,但不会看到c。
https://stackoverflow.com/questions/5316802
复制相似问题