Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log excluding branch

Consider the following commit history:

1---R---3---5---P->                  # patch-v1.1
     \       \
      2---4---+---8---+---10---R->   # release-v2.0
           \         /
            6---7---9                # feature-foo

--> time

# 1 - 10 are commits
# P is a patch release commit
# R are major release commits
# + marks a merge commit

I want to generate the changelog for release-v2.0, but since P (patch-v1.1) has already been released, it's changes should not be part of the v2.0 changelog. Can I configure the git log command to only list commits 2, 4, 6 .. 11 (i.e., commits from release-v2.0 and feature-foo)?

like image 564
Clashsoft Avatar asked Feb 29 '16 16:02

Clashsoft


People also ask

Does git log show all branches?

Many times it's useful to know which branch or tag each commit is associated with. The --decorate flag makes git log display all of the references (e.g., branches, tags, etc) that point to each commit.

What is git log -- Oneline?

Git Log OnelineThe oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message. It will be used as follows: $ git log --oneline.

What does git log -- all do?

log --all is only for listing commits referenced in refs/ (like tags, heads, ...) The same page also says: The --all option does not tell git log to display all commits. It asks for the logs of all refs, basically your branches and tags.


1 Answers

Use git log R --not P. That's the same as git log P..R from @micha-wiedenmann's comment, but I find the former syntax more speaking. And yes, it will include 2, 4, 6, 7, 9 as it does not matter when they chronologically happened (in terms of time authored), but where they are in the DAG. With R --not P you basically create the complement of P in R in terms of set theory.

like image 174
sschuberth Avatar answered Sep 19 '22 13:09

sschuberth