Limit refs shown with git log --decorate
Asked Answered
C

4

9

I have 3 standard remotes for a the main repository I work in currently: a local backup, my development partner's workstation, and a hosted repository. We have 3 or 4 branches that are active most of the time, one being master.

I monitor the branches on a regular basis throughout the day using:

git log --graph --oneline --decorate -15 my-branch his-repo/his-branch master other-branch

--decorate is crucial because it lets me know the state of things in regards to our very volatile development branches. The problem is that I see all of the remote refs and all of the branches, tags, etc. in the decoration.

Is there any way to limit --decorate to only output certain refs? Listing the refs on the command line only limits the commits shown, not the refs shown.

Thanks, Mike

Carat answered 20/2, 2012 at 19:10 Comment(0)
M
4

You cannot limit this out-of-the box. But nothing is stopping you from scripting the manipulation of .git/refs and then restoring it right after :).

Molotov answered 20/2, 2012 at 19:23 Comment(3)
Manipulating refs isn't a bad idea except that I also have to take into account packed-refs. Though perhaps once I wrote the script it would find other uses... Then again, a hard-coded script to rename refs and packed-refs and insert a simple packed-refs file with the correct hashes might be fairly straight-forward. The biggest danger I see in this is any other processes that might be accessing the repo (IDEs, etc.).Carat
I never integrate source control with any IDE. Then again, I'm in the .NET world where there is no trust of OSS ;)Molotov
I'm in .NET mostly as well. I use the git source control provider mainly for doing a quick diff, history, or blame. I use TortoiseGit mainly for the Show Log.Carat
L
4

Starting with Git 2.16, the option --decorate-refs-exclude allows:

--decorate-refs=
--decorate-refs-exclude=

If no --decorate-refs is given, pretend as if all refs were included. For each candidate, do not use it for decoration if it matches any patterns given to --decorate-refs-exclude or if it doesn’t match any of the patterns given to --decorate-refs.

Levalloisian answered 1/8, 2019 at 9:10 Comment(0)
F
3

No. If you're using decorate, it will use all available names as decorations. --decorate=short will reduce the clutter, but not reduce the total number of decorations you're going to be looking at.

You could write a script which decorates the output of git log yourself quite easily, if you need this specific functionality.

Fariss answered 20/2, 2012 at 19:13 Comment(3)
Decorating myself might be an option. I'd have to preserve the --graph formatting, since the graph and the decorations are key to what I'm monitoring. Perhaps using cut and paste would work.Carat
@Carat if you end up scripting something like this, please share :)Cattan
@TobyJ - I did not :( Necessity hasn't been great enough to get me to spend the time on it and not enough spare cycles to do it for fun.Carat
W
0

This works for me...

git log --decorate-refs-exclude 'refs/tags/*'
Widespread answered 2/12, 2021 at 10:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.