I regularly use the following git-log
command:
git log --oneline --graph --decorate --all
The command is perfect for me, with one exception. I maintain a set of refs
in refs/arch/
that I want to keep around ("arch" stands for "archive"), but I do not want to see them every time I look at my git log. I don't mind them showing up if they are an ancestor of an existing branch
or tag
, but I really do not want to see series of commits that would not otherwise show up in the git log but for the fact that they are in the commit history of a given refs/arch/*
ref
.
For example, in the image below, the left-hand side is an illustration of what I see currently when I run git log --oneline --graph --decorate --all
. As you can see, the commit referred to by refs/arch/2
would not show up in the log if that ref
didn't exist. (Assume there are no refs
that are not shown in the left-hand side image.) Now, the right-hand side is an illustration of two alternative log graphs, either of which would be perfectly fine. I don't mind seeing anything matching refs/arch/*
so long as it is in the commit history of a branch
or tag
. But, in the image below, I definitely do not want to see the commit referred to by refs/arch/2
.
How can my git-log
command be modified to suppress refs/arch/*
in either of the senses depicted in the illustration?
What you want is:
git log --oneline --graph --decorate --exclude 'refs/arch/*' --all
The --exclude
option is new in git 1.9.0.
From the git-log manual page:
--exclude=<glob-pattern>
Do not include refs matching
<glob-pattern>
that the next--all
,--branches
,--tags
,--remotes
, or--glob
would otherwise consider. Repetitions of this option accumulate exclusion patterns up to the next--all
,--branches
,--tags
,--remotes
, or--glob option
(other options or arguments do not clear accumlated patterns).The patterns given should not begin with
refs/heads
,refs/tags
, orrefs/remotes
when applied to--branches
,--tags
, or--remotes
, respectively, and they must begin withrefs/
when applied to--glob
or--all
. If a trailing/*
is intended, it must be given explicitly.
If you are on some flavor of Ubuntu you can upgrade git from the Ubuntu Git Maintainers team ppa.
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get upgrade
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With