Andrew
Andrew

Reputation: 4418

How do I filter out git-log commits that are topologically irrelevant?

I'm trying to visualize the relationship between branches in a git repository. There's a lot of commits in them, so git log --oneline --graph and git show-branch have a lot of noise.

I'd like the graph to show only:

Can this be done?

Upvotes: 0

Views: 141

Answers (1)

jthill
jthill

Reputation: 60235

You can get close with --simplify-by-decoration, that will additionally list commits that have a tag on them. To cut unwanted chatter you can use one of my favorite tricks,

git clone -ns --no-tags . `mktemp -d`
git -C $_ log --graph --decorate --oneline --all --simplify-by-decoration

That clone will be tiny, for the linux repo it's 36KB.

This doesn't list the direct parents of every merge, it picks different parts of the ancestry to show the structure as compactly as possible without losing any of it, but it may be close enough to serve.

You can't find children of a commit starting from that commit, you have to walk back from all the tips you care about, so if a commit's not in any branch this won't find it.But then, if a commit's not in any history, it's not really going anywhere anyway, so...

Upvotes: 2

Related Questions