I want to do something that Gitk already does, except in the command line. I want to display all the commits from one branch, plus all commits from another branch, but no other history. Let's be more specific : I am talking about a feature branch plus the main branch, but no other stuff (however much else there is). How to achieve this ?
By "Commit from a branch" I mean a commit that was explicitly committed (and pushed) on the branch, not one that was brought by a merge. It is enough for me to see that a commit is actually a merge, as I expect to see in the commit message with which other branch this is a merge, which tells me enough here.
To achieve this in Gitk : I create a view in which I list the branches I want to see, and I check "Limit to first parent".
An example.
L-M : other stuff
\
A-B-C-I : feature
/
... -D-E-F-J : main
/ /
/ G-H-K : more other stuff
/
... potentially even more stuff contributing to main via merges (not explicitly known)
C is the result of the merge of B and F.
E is the result of the merge of D and H.
B is the result of the merge of A and M.
I want to see A, B, C, I, D, E, F and J, but not G, H,K, L and M.
A-B-C-I - feature
/
D-E-F-J - main
Bonus : do not see J either ...
Bonus to the bonus : ... but somehow know that F was once main and label it as such.
A-B-C-I - feature
/
D-E-F - was main
Edit : If I use --first-parent main feature I almost get what I want, except the second parent merge relationships are not shown (even though they exist, Gitk shows them). What now ?
Gis part ofmainandfeature(as isLafter the edit). It's part of their history. Is there some other branch pointing toK, so you can at least filter out everything reachable from that?mainand then also ask not to seeJ? Is this a different question? Did you not really want to seemainat all, but just commits reachable from bothmainandfeature?gitk?Ehas two ancestors,DandH. There is no sense in which git knows thatDis "more main" thanH(and thereforeG). You know this, because it's metadata that you hold in your head. It isn't recorded in the commit history. If you want git to figure this stuff out for you, you need to first figure out how to add enough metadata to your repo that it has something to go on.Dcould be "more main" thanH.