简体   繁体   中英

SVN command-line: Find current HEAD revision of a branch

As part of a script I'm writing, I'm trying to grab the latest revision number within a given branch in SVN.

I had tried the following code (where ${sourcebranch} is the SVN URL for my branch):

svn info ${sourcebranch} | awk '/Revision/ { print $2; }'

However, this seems to give me the latest revision number for the entire repository , not just the branch.

I really just want the branch... any ideas?

Use log instead:

svn log --limit 1 ${sourcebranch} 

This will return the last commit to the branch, similar to this output:

------------------------------------------------------------------------
r14159 | author_name | 2014-04-25 18:54:49 -0400 (Fri, 25 Apr 2014) | 5 lines

log message

------------------------------------------------------------------------

From there, just parse the r#### field.

“修订”值应用于整个仓库,您需要“最后更改的修订”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM