Problems with git commit count

We use a git command to generate build numbers in a way which works for CI and for developer machines, but when we run this command on CircleCI we get a different result. Is there any reason why the command git rev-list --count HEAD would return a different (lower) number when run on CircleCI than on any of our other machines? I’ve run this command with a newly cloned repo and I get the correct number, it’s only on CircleCI that I get the wrong number.

The reply from CircleCI team was:

In order to reduce our burden on GitHub, we do a shallow clone instead of a full one. If this is a problem, you can try running git fetch --unshallow prior to running git rev-list --count HEAD.

5 Likes