Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git last tag value for git log pretty format?

Tags:

git

I'm trying to generate some release notes using the following:

git log --pretty=format:%s my-project-1.2..HEAD

However, how can I reuse something similar to this generically after each new rev instead of specifying the last known good rev (everytime) to work from (one down from head)?

i.e

git log --pretty=format:%s [somehow get my-project-last-rev so I don't have to specify]..HEAD

like image 207
genxgeek Avatar asked Jun 06 '14 21:06

genxgeek


People also ask

How do I get the most recent tags in git?

In order to find the latest Git tag available on your repository, you have to use the “git describe” command with the “–tags” option. This way, you will be presented with the tag that is associated with the latest commit of your current checked out branch.

How do I tag last commit?

In order to create a Git tag for the last commit of your current checked out branch, use the “git tag” command with the tag name and specify “HEAD” as the commit to create the tag from. Similarly, if you want your tag to be annotated, you can still use the “-a” and “-m” options to annotate your tag.

What is the output of the code git log pretty Oneline?

Git Log Oneline The 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 -- Decorate do in git log?

The --decorate flag makes git log display all of the references (e.g., branches, tags, etc) that point to each commit. This lets you know that the top commit is also checked out (denoted by HEAD ) and that it is also the tip of the main branch.


1 Answers

git describe --abbrev=0 --tags should give you the lastest tag "under" your current branch, so you could just use back-ticks to execute it inline:

git log --pretty=format:%s `git describe --abbrev=0 --tags`..HEAD
like image 171
Mureinik Avatar answered Oct 03 '22 18:10

Mureinik