Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

git log graph smart filter on branches

Since I have multiple colleagues in my team pushing out considerable amount of branches, whenever I want to disentangle my own branches I’d like to get a clear overview of only those. In summary I want to use git log --graph --oneline --decorate but only on branches:

  • that are my own local branches
  • that are specified as the upstream of any of my own local branches

Is there a git command that can realize this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

First, you can have all local branches with --branches.

Then, for the remote branches your local branches are tracking, you’ll have to do a bit of mapping through git for-each-ref for instance:

git log --graph --branches $(git for-each-ref --format="%(upstream:short)" refs/heads | sort -u)

(But beware of missing remote references. If you have local branches pointing to deleted remote refs, this will fail with a missing reference error.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading