Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Count commits since tag

Tags:

git

I am trying to count the number of commits since a tag was made.

I have tried using git rev-list but it seems to return the same results no matter what I try. This is what I have tried:

$ git rev-list 1.7Start^..HEAD | wc -l
13902
$ git rev-list HEAD | wc -l
13902

Trying to count how many commits since the 1.7Start tag was created. I'm currently on master hence using HEAD but using git rev-list master | wc -l gives me the same.

There hasn't been 13000+ commits since 1.7

Should git rev-list master show me every commit in master and hence yield a larger number than 1.7Start^..master which should just give me the difference?

like image 939
Nathan W Avatar asked May 31 '12 05:05

Nathan W


People also ask

What is git describe dirty?

If the working tree has local modification "-dirty" is appended to it. If a repository is corrupt and Git cannot determine if there is local modification, Git will error out, unless '--broken' is given, which appends the suffix "-broken" instead. --all.

How do I know if a commit is part of a tag?

Check the documentation for git describe . It finds the nearest tag to a given commit (that is a tag which points to an ancestor of the commit) and describes that commit in terms of the tag. In newer versions, git describe --tags --abbrev=0 REV will be useful when you don't want the junk on the tag.

How do I see git tags?

Find Latest Git Tag Available 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.


2 Answers

The results that you're getting suggest that there is no history in common between 1.7Start^ and HEAD, so 1.7Start and HEAD must have different root commits. (The syntax a..b when passed to git rev-list just means "every commit in b which isn't in a.)

In the comments above, the questioner indicated that this arose because the repository was migrated from Subversion, and master is entirely distinct from the imported branch that 1.7Start points to.

like image 86
Mark Longair Avatar answered Sep 16 '22 20:09

Mark Longair


Git has git rev-list --count which does this faster then wc-l.

There is also the git rev-list --use-bitmap-index --count in later versions of git, which is an optimization of --count.

rev-list needs a commit, so an example, to find all the commits in your repo for your current branch.

git rev-list --count HEAD 
like image 22
lsiebert Avatar answered Sep 19 '22 20:09

lsiebert