How to simplify git log to show only certain commits and their merge bases?

For example, if I do:

git log --oneline --graph --decorate master branch dcfadf1

I see all commits:

* e8599bb (HEAD -> branch) branch5
* 2fe1c92 branch4
| * f083d02 (master) master5
| * d33bf64 master4
|/  
* a286c74 master3
* dcfadf1 master2
* 6f58634 master1

However, I'd like to see instead only:

* e8599bb (HEAD -> branch) branch5
| * f083d02 (master) master5
|/  
* a286c74 master3
* dcfadf1 master2

to better understand how those specific commits are related.

Why each of those commits those should appear:

I can't use --simplify-by-decoration, since my actual repo has a lot of branches I don't care about, and furthermore it removes merge bases by default: http://git.661346.n2.nabble.com/quot-git-log-simplify-by-decoration-quot-but-including-branch-amp-merge-points-td6825766.html

Here is the test repo which corresponds to the above git log commands: https://github.com/cirosantilli/test-so-46270360

git clone https://github.com/cirosantilli/test-so-46270360
cd test-so-46270360
git checkout master
git checkout -

Upvotes: 6

Views: 1258

Answers (1)

Doron Behar
Doron Behar

Reputation: 2878

As noted in the comments, --graph makes no sense if you intend to see commits not necessarily related to each other. Hence I'd advice you to drop --graph and you'll be able to use --no-walk.

Here's git log's documentation of --no-walk for reference:

Only show the given commits, but do not traverse their ancestors. This has no effect if a range is specified. If the argument unsorted is given, the commits are shown in the order they were given on the command line. Otherwise (if sorted or no argument was given), the commits are shown in reverse chronological order by commit time. Cannot be combined with --graph.

So for your example, I'd use:

git log --oneline --no-walk --decorate master branch dcfadf1

Upvotes: 1

Related Questions