Limit refs shown with git log --decorate

2019-06-16 03:45发布

问题:

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

回答1:

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



回答2:

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.



标签: git git-log