git Git在日志中显示所有分支(但不是隐藏)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9437182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:03:01  来源:igfitidea点击:

Git show all branches (but not stashes) in log

gitgit-loggit-stash

提问by cYrus

I have a Git alias that expands to:

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

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

According to man git logthere are a couple of suspicious options: --notand --branches; but I can't make it work properly.

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

How should I edit that to hide the stashes?

我应该如何编辑它以隐藏隐藏?



FYI: as per the accepted questionand commentmy .gitconfigalias now looks like this:

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

[alias]
    l = log --branches --remotes --tags --graph --oneline --decorate --notes HEAD

回答by Andrew Marshall

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

不要做--all然后试图过滤掉隐藏的东西,永远不要把它们放在首位:

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 headof 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.

之后尝试将它们过滤掉的主要问题是,如果 stash 是该分支上的最新提交(因为即使它不是head分支的,它仍然是它的最新后代),它实际上可以过滤掉日志中的整个分支,这不是您想要的。

回答by five

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 lfor the current branch
  • git l feature234for a specific branch
  • git l --allfor the overall history
  • git l对于当前分支
  • git l feature234对于特定分支
  • git l --all对于整个历史

From the manual:

从手册:

--exclude=<glob pattern>

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

--exclude=<glob 模式>

不要包括下一个 --all、--branches、--tags、--remotes 或 --glob 会考虑的引用匹配。

回答by Jakub Nar?bski

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

请注意,Andrew 的答案不适用于隐藏StGit 1.)分支<branch>.stgit(来自 StGit 0.15 版),否则会导致输出乱七八糟,使其无法使用。

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).

1.)StGit( “ACKED GIT中”)提供了被子/ MQ -等功能GIT中(即,从一个堆入栈/出栈的补丁/)。