[英]Built-in command to checkout a specific Subversion revision which doesn't use the 'rNNNNN' format from a Git mirror?
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. 我是从Subversion存储库的本地Git镜像进行编译的,我需要从该镜像的Subversion版本号中检出特定的提交。
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. git log
显示如下内容:通过找到git-svn-id: xxxx xxxx@revision-number
行,应该可以找到正确的引用并将其检出。 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? git svn find-rev
在Checkout中引用了与旧SVN信息库中的某个修订相对应的git commit? 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. 适用于使用修订号为
rN
样式的存储库,并非适用于所有SVN存储库,这一点也适用。 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
: 如果您的本地存储库由
git svn
管理,则可以使用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. 我希望您在本地Git镜像上仍然有一个svn-remote分支。 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
Following the answer from How do I show the SVN revision number in git log? 遵循我如何在git log中显示SVN版本号的答案? , my solution is to
grep
for the revision id an cut
out the Git commit hash. ,我的解决方案是使用
grep
作为修订版ID,以cut
Git commit哈希。
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. 如果NNNNN字符串出现在另一个不是提交ID的提交消息中,则
trunk
将匹配NNNNN字符串的机会降到最低。 The hash can be shortened by piping the output through another cut -b 1-8
可以通过将输出通过另一个
cut -b 1-8
来缩短哈希值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.