Git 在日志中显示所有分支(但不显示存储)

我有一个 Git 别名,可以扩展为:

git log --graph --oneline --all --decorate

根据 man git log的说法,有两个可疑的选项: --not--branches; 但是我不能让它正常工作。

我该怎么编辑这个来隐藏藏起来的东西呢?


供参考: 根据 接受的问题评论,我的 .gitconfig别名现在看起来是这样的:

[alias]
l = log --branches --remotes --tags --graph --oneline --decorate --notes HEAD
27759 次浏览

Instead of doing --all and then trying to filter out the stashes, don't ever include them in the first place:

git log --branches --remotes --tags --graph --oneline --decorate

The main problem that arises from trying to filter them out afterwards is that if the stash is the latest commit on that branch (because even though it's not the head of the branch, it's still the most recent descendant of it), it can actually filter out the entire branch from the log, which isn't what you want.

Note that Andrew's answer wouldn't work for hiding StGit1.) branches <branch>.stgit (from StGit version 0.15) which otherwise litter the output making it unusable.

Currently I use the following solution:

$ git log --graph --oneline --decorate \
$(git for-each-ref --format="%(refname)" refs/heads/ refs/remotes/ |
grep -v "\.stgit$")

1.) StGit ("Stacked Git") provides Quilt/mq--like functionality to Git (i.e. pushing/popping patches to/from a stack).

My alias:

[alias]
l = log --oneline --decorate --graph --exclude=refs/stash

In this case you will be able to use these forms without showing the stash:

  • git l for the current branch
  • git l feature234 for a specific branch
  • git l --all for the overall history

From the manual:

--exclude=<glob pattern>

Do not include refs matching that the next --all, --branches, --tags, --remotes, or --glob would otherwise consider.