285

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) ?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
telemaco
  • 3,103
  • 2
  • 16
  • 8

7 Answers7

333

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

dumbledad
  • 16,305
  • 23
  • 120
  • 273
manojlds
  • 290,304
  • 63
  • 469
  • 417
34

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

git log --pretty=oneline HEAD...tag
szaman
  • 6,666
  • 13
  • 53
  • 81
hidro
  • 12,333
  • 6
  • 53
  • 53
32

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.

Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
Ben Stiglitz
  • 3,994
  • 27
  • 24
25

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
lual
  • 416
  • 4
  • 6
5

Consider also this:

git range-diff tagA...tagB

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

foreignmeloman
  • 109
  • 2
  • 4
4

FYI:

git log tagA...tagB

provides standard log output in a range.

starsinmypockets
  • 2,264
  • 4
  • 34
  • 45
4

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).
Balu Ertl
  • 313
  • 5
  • 6