如何 git-svn 从 Subversion 存储库克隆最后 n 个修订版? [英] How to git-svn clone the last n revisions from a Subversion repository?

查看:21
本文介绍了如何 git-svn 从 Subversion 存储库克隆最后 n 个修订版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

如何使用 git-svn 从 Subversion 存储库创建浅拷贝,例如你怎么只拉最后三个修订版?

How do you create a shallow copy with git-svn from a Subversion repository, e.g. how do you pull only the last three revisions?

如果您使用选项 --depthgit clone 命令可以从 Git 存储库中获取最后 n 个修订版,即您获得存储库的浅拷贝.示例:

The git clone command can get the last n revisions from a Git repository if you use the option --depth, i.e. you get a shallow copy of the repository. Example:

git clone --depth 3 git://some/repo myshallowcopyrepo

git-svn 有没有类似的选项?

Is there a similar option for git-svn?

我目前的发现

到目前为止,我只找到了 -rN 选项,其中 N 是要提取的修订版.示例:

So far I've only found the -rN option where N is the revision to pull. Example:

git svn clone -rN svn://some/repo

根据文档,可以使用 -r$REVNUMBER:HEAD.我尝试了以下方法来获取返回错误消息的最后 3 个修订版.

According to the documentation there is the possibility to use -r$REVNUMBER:HEAD. I tried the following to get the last 3 revisions which returned an error message.

$ git svn clone --prefix=svn/ -s -rHEAD~3:HEAD http://some/svn/repo .
revision argument: HEAD~3:HEAD not understood by git-svn

所以我将 HEAD~3 替换为第三次但最后一次修订的实际编号 534.这可行,但这需要我首先找出第三次但最后一次提交的修订号.

So I replaced HEAD~3 with the actual number of the third but last revision 534. That worked, but that requires me to first figure out the revision number of the third but last commit.

$ git svn clone --prefix=svn/ -s -r534:HEAD http://some/svn/repo .

文档

git-clone

git-svn

推荐答案

您已经发现了在 Git-SVN 中指定浅层克隆的最简单方法,通过指定要开始克隆的 SVN 修订号 (-r$REV:HEAD).

You've already discovered the simplest way to specify a shallow clone in Git-SVN, by specifying the SVN revision number that you want to start your clone at ( -r$REV:HEAD).

例如:git svn clone -s -r1450:HEAD some/svn/repo

Git 的数据结构基于有向无环图 (DAG) 中的指针,这使得回溯 n 次提交变得微不足道.但是在 SVN 中(因此在 Git-SVN 中)你必须自己找到修订号.

Git's data structure is based on pointers in a directed acyclic graph (DAG), which makes it trivial to walk back n commits. But in SVN ( and therefore in Git-SVN) you will have to find the revision number yourself.

这篇关于如何 git-svn 从 Subversion 存储库克隆最后 n 个修订版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆