I am compiling from a local Git mirror of a Subversion repository and I need to checkout out particular commits from the Subversion revision number from the mirror.
The git log
displays something like this: and by locating the git-svn-id: xxxx xxxx@revision-number
line it should be possible to locate the right reference and check it out. But there are lots of revisions and it is bound to get awkward if I want to go way back in time. Is there a built-in to accomplish this?
commit xxxx-yyyy-fb12992fabd6a1165697ded73851d26993
Author: mattias <mattias@4005530d-fff6-0310-9dd1-cebe43e6787f>
Date: Fri Mar 6 16:25:06 2015 +0000
fpcunit: guitestrunner: scroll to first error after run, patch from Graeme, issue 27613
git-svn-id: http://svn.freepascal.org/svn/lazarus/trunk@48152 4005530d-fff6-0310-9dd1-cebe43e6787f
UPDATE: relating to possible duplicate. git svn find-rev
referenced in Checkout the git commit corresponding to a certain revision from the old SVN repository? applies to repositories that use the rN
style of revision number, and that is not the case for all SVN repositories, and this one as well. Using it results in the error messages similar to the one below.
fatal: Not a valid object name 95059
cat-file commit 95059: command returned error: 128
If your local repository is being managed with git svn
, then you can use git svn find-rev
:
find-rev
When given an SVN revision number of the form rN, returns the
corresponding Git commit hash (this can optionally be followed by a
tree-ish to specify which branch should be searched). When given a
tree-ish, returns the corresponding SVN revision number.
For example:
git svn find-rev r48152
I hope you still have an svn-remote branch on your local Git mirror. With this it should be very simple. Try this.
git svn fetch <svn-remote>
git checkout remotes/<Remote Name>
git svn log --show-commit --oneline
Refer my answer from here .
Following the answer from How do I show the SVN revision number in git log? , my solution is to grep
for the revision id an cut
out the Git commit hash.
git log -z | tr '\n\0' ' \n' | sed 's/\(commit \S*\) .*git-svn-id: \
svn:[^@]*@\([0-9]*\) .*/\1 r\2/' | grep trunk@NNNNN | cut -d " " -f 2
The trunk
minimizes the chance of matching the NNNNN string if it appears in another commit message in which is not the commit id. The hash can be shortened by piping the output through another cut -b 1-8
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.