使用时缩短引用:git log

编程入门 行业动态 更新时间:2024-10-28 04:20:44
使用时缩短引用:git log --graph --pretty = oneline --decorate = full --oneline(Shorten the refs when using: git log --graph --pretty=oneline --decorate=full --oneline)

我正在使用

git log --graph --pretty=oneline --decorate=full --oneline

获取以下提交图:

* 221b95b(HEAD,refs / remotes / origin / master,refs / remotes / origin / HEAD,refs / remotes / upstream / master,refs / heads / master)格式化提交

但显示完整的refs路径是不方便的,因为它太长了。 有没有办法缩短它以缩短路径如下?:

* 221b95b(HEAD,origin / master,origin / HEAD,upstream / master,master)格式化提交

I'm using

git log --graph --pretty=oneline --decorate=full --oneline

to get the following commit graph:

* 221b95b (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/remotes/upstream/master, refs/heads/master) Formatting commit

but showing the full refs path is inconvenient as it is too long. is there a way to shorten it to get the paths shorten as follows?:

* 221b95b (HEAD, origin/master, origin/HEAD, upstream/master, master) Formatting commit

最满意答案

只需使用--decorate而不是--decorate=full ,因为short是默认值--decorate ,如git log文档中所述 (粗体强调我的):

--decorate[=short|full|no]

打印出所有提交的引用名称。 如果指定short ,则不会打印引用名称前缀refs/heads/ , refs/tags/和refs/remotes/ 。 如果指定full,则将打印完整的ref名称(包括前缀)。 默认选项很 short 。

另外,正如jthill评论的那样 , - --pretty=oneline是多余的,因为--oneline已经在每行上列出了一些提交:

--oneline表示--pretty=oneline --abbrev-commit 。

所以把它们放在一起:

git log --graph --decorate --oneline

Just use --decorate instead of --decorate=full, since short is the default value of --decorate, as stated in the git log documentation (bold emphasis mine):

--decorate[=short|full|no]

Print out the ref names of any commits that are shown. If short is specified, the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will be printed. The default option is short.

Also, as jthill commented, --pretty=oneline is redundant, since --oneline already lists commits on one line each:

--oneline means --pretty=oneline --abbrev-commit.

So putting it all together:

git log --graph --decorate --oneline

更多推荐

本文发布于:2023-08-06 18:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1453752.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:git   log

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!