Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show git commit using number of commits since a tag

Tags:

With git describe you can get the number of commits since the last tag. If you only had the tag and the number of commits what is the best way to show the commit that was described?

I know you could use git log tag.. and pipe it to a a script that does the counting but I was hoping for a more elegant solution similar to git show tag~n.

To add more context, we are planning using git describe to create release numbers, for example with

$ git describe v1.5-39-g5ede964 

we would use foo_1.5.39. What we would like to do is knowing 1.5.39 means the 39th commit after the v1.5 tag, find that commit, i.e. find g5ede964. As pointed out in a comment, the 39th commit after v1.5 may not be unique. So perhaps a better way to ask this is what is the best way to find all commits X such that if HEAD was pointing to X git describe would return v1.5-39-*****.

like image 420
Joel Avatar asked Dec 21 '11 19:12

Joel


People also ask

What is the git command to view all the commits since?

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.

How can I see commit details?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

How do I display a commit?

By default, git-show acts against the HEAD reference. The HEAD reference always points to the last commit of the current branch. Therefore, you can use git-show to display the log message and diff output of the latest commit.


1 Answers

Try

git rev-list tag..HEAD --count 

OR

git rev-list tag.. --count 

They mean the same thing.

like image 154
Sam Avatar answered Sep 24 '22 01:09

Sam