如何从`git log`中排除一些标签?

时间:2016-03-28 19:12:15

标签: git

我有一个存储库,其中包含一个自动化流程,可以创建大量标签。例如:

* 5391e27 - (HEAD -> master, origin/master) Add a webhook to notify Phabricator of builds (2 hours ago) <Phil Frost>
* c380a48 - Retry downloading Selenium 3 times (2 hours ago) <Phil Frost>
| * 542731c - (tag: phabricator/diff/962) Retry downloading Selenium 3 times (6 hours ago) <Phil Frost>
|/
* 59509a3 - (tag: phabricator/base/962) Notify only on "master" branch (7 hours ago) <Phil Frost>
* 1504aa6 - Fix a few errors and omissions in README (7 hours ago) <Phil Frost>
| * a52940d - (tag: phabricator/diff/959) Notify only on "master" branch (3 days ago) <Phil Frost>
|/
| * 25838f0 - (tag: phabricator/diff/958) Notify only on "master" branch (3 days ago) <Phil Frost>
|/
* d7b3f72 - (tag: phabricator/base/959, tag: phabricator/base/958) Execute arbitrary commands in the test container (3 days ago) <Phil Frost>

通常,我不关心所有这些phabricator/*/*标记,因此我希望看到所有引用的日志,除了那些。换句话说,我想看到这个:

* 5391e27 - (HEAD -> master, origin/master) Add a webhook to notify Phabricator of builds (2 hours ago) <Phil Frost>
* c380a48 - Retry downloading Selenium 3 times (2 hours ago) <Phil Frost>
* 59509a3 - Notify only on "master" branch (7 hours ago) <Phil Frost>
* 1504aa6 - Fix a few errors and omissions in README (7 hours ago) <Phil Frost>
* d7b3f72 - Execute arbitrary commands in the test container (3 days ago) <Phil Frost>

我认为这样做会:

git log --exclude='refs/tags/phabricator/*/*' --all

不幸的是,--exclude似乎没有任何影响我尝试它。如何查看git日志中的所有引用,除了一些与模式匹配的标记?

3 个答案:

答案 0 :(得分:4)

作为替代方案,使用Git 2.16(2018年第一季度),标记名“git log --decorate”用于注释提交可以 现在仅限于可用参考的子集,其中包含两个附加选项--decorate-refs[-exclude]=<pattern>

commit 65516f5Rafael Ascensão (``)(2017年11月21日) 帮助:Kevin Daudt (Ikke)Junio C Hamano (gitster) (由Junio C Hamano -- gitster --合并于commit 6c3daa2,2017年12月13日)

  

log:添加选项以选择要装饰的

     

当使用log --decorate时,git会用all来装饰提交   可用的参考。虽然在大多数情况下这可能会产生预期的效果,   在某些情况下会导致输出过于冗长

     

介绍两个命令行选项,

     
      
  • --decorate-refs=<pattern>
  •   
  • --decorate-refs-exclude=<pattern>
      允许用户选择在装饰中使用哪些参考。
  •   
     

当给出“--decorate-refs=<pattern>”时,只有与之匹配的引用   图案用于装饰。与模式匹配的引用   给出“--decorate-refs-exclude=<pattern>”,从未使用过   装饰。

在你的情况下:

git log -n6 --decorate=short --pretty="tformat:%f%d" \
        --decorate-refs-exclude="tags/phabricator/*"

答案 1 :(得分:2)

这可能工作(最终可能):

  

-fx-background-color: #CCFF99;

我认为问题是git log --exclude='refs/tags/phabricator/*/*' --all;试试*/*。有--exclude='refs/tags/phabricator/*'只能出现在名称末尾的各种地方,这就是其中之一。 (获取refspecs也曾被限制为这样,但最近删除了这个限制。)

请注意,*仍会将--decorate添加到通过refs/tags/phabricator/foo/bar包含的提交中,该提交也会被标记(如果有的话)。也就是说,--all步骤使这些提交不会被添加,而不是装饰(如果已经包含它们)。

答案 2 :(得分:0)

git log --oneline --format=%s -- . ":(exclude)phabricator"