Possible Duplicate:
what is the git equivalent for revision number?
I have been using subversion for same time now, and would like to switch to git. Having read the manual I have only one reservation, I use svnversion to get a reference number that is: unique, short, monotonic with respect to time (always increases).
Constraint: If we can get a branch ID than the above requirements only have to be met for articles on the same branch. (Branch ID can be anything that can be compared for identity, “is this the release branch?”.
[The word article is used here to represent a computer program, document or something else that is generated from the content of the revision control system.]
Git has the advantage that it's MUCH better suited if some developers are not always connected to the master repository. Also, it's much faster than SVN. And from what I hear, branching and merging support is a lot better (which is to be expected, as these are the core reasons it was written).
What is Git-SVN? The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.
SVN is better than Git for architecture performance, binary files, and usability. And it may be better for access control and auditability, based on your needs.
The Git workflow is similar to SVN, but with an extra step: to create a new feature, you take an exact copy of the central repository to create your local repository on your local machine (you can think of this as your “local trunk”).
As fork0 stated there's no such equivalent for non-linear histories, you can anyway execute this to get the number of commits for the current branch:
git log --oneline | wc -l
This is what one of my team mates use for generating a build number to be used in the build scripts.
No, there is no such thing for non-linear history. But you might look at git describe
, its output will meet at least the two first criteria.
The point of the build number is to simplify a process to get a source code for a given build. You could use git show -s --pretty=format:%h
to get a sha1 number which uniquely identifies a version, so that any developer could checkout it in his repository.
However, the sha1 is not incremental number and it is impossible to have in most cases even with other VCSs. If you wish to have it, then it is better to introduce a Continuous Integration system (e.g. Jenkins) which will number builds incrementally and create tags for these numbers. In this case it will grow more moderately, because CI usually doesn't build each commit.
Also, the mentioned git describe
does a great job to generate good version names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With