我正在使用
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 --onelineto 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 --onelineJust 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更多推荐
发布评论