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
Git show all branches (but not stashes) in log
提问by cYrus
I have a Git alias that expands to:
我有一个 Git 别名,可以扩展为:
git log --graph --oneline --all --decorate
According to man git log
there are a couple of suspicious options: --not
and --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 .gitconfig
alias now looks like this:
仅供参考:根据接受的问题和评论,我的.gitconfig
别名现在看起来像这样:
[alias]
l = log --branches --remotes --tags --graph --oneline --decorate --notes HEAD
回答by Andrew Marshall
Instead of doing --all
and 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 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.
之后尝试将它们过滤掉的主要问题是,如果 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 l
for the current branchgit l feature234
for a specific branchgit l --all
for 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中(即,从一个堆入栈/出栈的补丁/)。