The most basic and powerful tool to do this is the git log command. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.
To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..
We occasionally have two tags on the same commit. When we use git describe for that commit, git describe always returns the first tag. My reading of the git-describe man page seems to indicate that the second tag should be returned (which makes more sense).
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
To compare between latest commit of current branch and a tag:
git log --pretty=oneline HEAD...tag
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.
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
FYI:
git log tagA...tagB
provides standard log output in a range.
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 listold-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).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With