I use svn in command line. How can I get the head version number in command line. I need the number,not only to see the info . I want to use this number to build my project automatic.
Asked
Active
Viewed 7,907 times
7
-
Just in case you're interested in the *revision number*: http://stackoverflow.com/questions/579196/getting-the-last-revision-number-in-svn – Andreas Dolk Aug 09 '12 at 07:03
1 Answers
11
As the comment below mentioned, this can be achieved by the following command in the newer SVN clients:
svn info -rHEAD --show-item revision
Original Answer
Here is simple shell script thingy for you. Execute: svn info -rHEAD | grep Revision | cut -d' ' -f2
See it in action:
main$ svn info -rHEAD
Path: main
URL: svn://url/trunk/main
Repository Root: svn://url
Repository UUID: xxxxx-xxxx-xxxx-xxxx-xxxxxxxx
Revision: 17042
Node Kind: directory
Last Changed Author: Nishant
Last Changed Rev: 17040
Last Changed Date: 2012-08-09 11:29:05 +0530 (Thu, 09 Aug 2012)
main$ svn info -rHEAD | grep Revision | cut -d' ' -f2
17042
Edit1: updated to fetch head rev.

Nishant
- 54,584
- 13
- 112
- 127
-
Thank you very much! This is just I want! Thank you angain! @Nishant – qiushuitian Aug 09 '12 at 07:55
-
2Note that modern `svn` has support for this without having to grep and cut: `svn info -rHEAD --show-item revision` – Andy Lester Jan 22 '23 at 18:58