Get commit list between tags in git

Git

Git Problem Overview


If I've a git repository with tags representing the versions of the releases.

How can I get the list of the commits between two tags (with a pretty format if is possible) ?

Git Solutions


Solution 1 - Git

git log --pretty=oneline tagA...tagB (i.e. three dots)

If you just wanted commits reachable from tagB but not tagA:

git log --pretty=oneline tagA..tagB (i.e. two dots)

or

git log --pretty=oneline ^tagA tagB

Solution 2 - Git

To compare between latest commit of current branch and a tag:

git log --pretty=oneline HEAD...tag

Solution 3 - Git

git log takes a range of commits as an argument:

git log --pretty=[your_choice] tag1..tag2

See the man page for git rev-parse for more info.

Solution 4 - Git

To style the output to your preferred pretty format, see the man page for git-log.

Example:

git log --pretty=format:"%h; author: %cn; date: %ci; subject:%s" tagA...tagB

Solution 5 - Git

FYI:

git log tagA...tagB

provides standard log output in a range.

Solution 6 - Git

Consider also this:

git range-diff tagA...tagB

Source: https://git-scm.com/docs/git-range-diff

Solution 7 - Git

If your team uses descriptive commit messages (eg. "Ticket #12345 - Update dependencies") on this project, then generating changelog since the latest tag can de done like this:

git log --no-merges --pretty=format:"%s" 'old-tag^'...new-tag > /path/to/changelog.md
  • --no-merges omits the merge commits from the list
  • old-tag^ refers to the previous commit earlier than the tagged one. Useful if you want to see the tagged commit at the bottom of the list by any reason. (Single quotes needed only for iTerm on mac OS).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontelemacoView Question on Stackoverflow
Solution 1 - GitmanojldsView Answer on Stackoverflow
Solution 2 - GithidroView Answer on Stackoverflow
Solution 3 - GitBen StiglitzView Answer on Stackoverflow
Solution 4 - GitlualView Answer on Stackoverflow
Solution 5 - GitstarsinmypocketsView Answer on Stackoverflow
Solution 6 - GitforeignmelomanView Answer on Stackoverflow
Solution 7 - GitBalu ErtlView Answer on Stackoverflow