Git equivalent svnversion

Possible duplicate:
What is the git equivalent for version number?

I am using subversion for the same time now and would like to switch to git. After reading the manual, I have only one caveat, I use svnversion to get a reference number that is unique, short, monotonous in time (always increasing).

  • It must be unique, so I can use it to play the article.
  • It should be short, so it is readable, it can be used in file names, page footers, version number mappings.
  • It should only increase (monotonously with respect to time), so anyone can compare the age of two articles without knowing the age (date).

Restriction: if we can get a branch identifier than the above requirements, it is necessary to fulfill only for articles in the same branch. (The branch identifier can be anything that can be compared to identify, "is this a release branch?"

[The article is used here to present a computer program, document, or something else created from the contents of a version control system.]

+4
source share
4 answers

As indicated in fork0 there is no such equivalent for nonlinear stories, you can do this anyway to get the number of commits for the current branch:

git log --oneline | wc -l 

This is what one of my teammates uses to create the build number that will be used in build scripts.

+5
source

No, there is no such thing for a nonlinear story. But you can look at git describe , its result will correspond to at least the first two criteria.

+3
source

The assembly number point is a simplification of the process for obtaining the source code for a given assembly. You can use git show -s --pretty=format:%h to get a sha1 number that uniquely identifies the version so that any developer can check it in their repository.

However, sha1 is not an incremental number, and in most cases it cannot be used even with other VCSs. If you want to get it, it is better to introduce a continuous integration system (for example, Jenkins), which will increase the number in stages and create tags for these numbers. In this case, it will grow more moderately, because CI usually does not create every commit.

In addition, the aforementioned git describe does a great job of creating good version names.

+1
source

Smudge | clean filters allows you to build any identifier, YYYYMMDD-N (where N is the commit counter for this date) may be a good choice

0
source

Source: https://habr.com/ru/post/1434813/


All Articles