简体   繁体   English

内置命令可以检出特定的Subversion版本,而该版本不使用Git镜像中的'rNNNNN'格式?

[英]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-revCheckout中引用了与旧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

Refer my answer from here . 这里参考我的答案。

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.

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