如何 git-svn 从 Subversion 存储库克隆最后 n 个修订版本?
问题
如何使用 git-svn 从 Subversion 存储库创建浅副本,例如如何仅提取最后三个修订版本?
如果您使用选项--深度
,则git clone
命令可以从Git存储库获取最后n个修订,即您获得存储库的浅表副本。 示例:
git clone --depth 3 git://some/repo myshallowcopyrepo
git-svn 有类似的选项吗?
到目前为止我的发现
到目前为止,我只找到了 -rN
选项,其中 N
是要拉取的修订版本。 示例:
git svn clone -rN svn://some/repo
根据文档,可以使用 -r$REVNUMBER:HEAD
。 我尝试了以下方法来获取返回错误消息的最后 3 个修订版。
$ 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 的实际编号。这有效,但这需要我首先找出第三个但最后一个提交的修订版本号。
$ git svn clone --prefix=svn/ -s -r534:HEAD http://some/svn/repo .
文档
Problem
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?
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
Is there a similar option for git-svn?
My discoveries so far
So far I've only found the -rN
option where N
is the revision to pull. Example:
git svn clone -rN svn://some/repo
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
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 .
Documentation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您已经发现了在 Git-SVN 中指定浅层克隆的最简单方法,即指定要在其处启动克隆的 SVN 修订号 (
-r$REV:HEAD
)。例如: git svn clone -s -r1450:HEAD some/svn/repo
git 的数据结构基于有向无环图 (DAG) 中的指针,这使得回溯变得微不足道n 提交。 但在 SVN 中(因此在 Git-SVN 中)您必须自己找到修订号。
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
).For example:
git svn clone -s -r1450:HEAD some/svn/repo
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.我发现自己经常使用以下命令从我们巨大的颠覆树中获得有限数量的修订(我们很快就会达到 svn 修订 35000)。
找出分支开始位置的一个好方法是执行 svn log 并找到分支上的第一个(执行时列出的最后一个):
到目前为止,我还没有真正找到跟踪所有分支机构的麻烦是值得的。 克隆需要太多时间,而且 svn 和 git 不能像我希望的那样很好地协同工作。 我倾向于创建补丁文件并将它们应用到另一个 svn 分支的 git 克隆上。
I find myself using the following often to get a limited number of revisions out of our huge subversion tree (we're soon reaching svn revision 35000).
And a good way to find out where a branch started is to do a
svn log
it and find the first one on the branch (the last one listed when doing):So far I have not really found the hassle worth it in tracking all branches. It takes too much time to clone and svn and git don't work together as good as I would like. I tend to create patch files and apply them on the git clone of another svn branch.
... 7 年后,在沙漠中,风滚草吹过...
我对接受的答案并不满意,因此我创建了一些脚本来为您执行此操作 可在 Github 上获取。 这些应该可以帮助任何想要使用 git svn clone ,但不想克隆整个存储库并且不想从历史记录中间寻找要克隆的特定修订版的人(也许你正在克隆一堆存储库)。 在这里,我们可以克隆最后 N 个修订版:
使用 git svn clone 克隆最后 50 个修订版
从 SVN 存储库查找前 N 个修订版
... 7 years later, in the desert, a tumbleweed blows by ...
I wasn't satisfied with the accepted answer so I created some scripts to do this for you available on Github. These should help anyone who wants to use
git svn clone
but doesn't want to clone the entire repository and doesn't want to hunt for a specific revision to clone from in the middle of the history (maybe you're cloning a bunch of repos). Here we can just clone the last N revisions:Use
git svn clone
to clone the last 50 revisionsFind the previous N revision from an SVN repo
尝试使用SVN存储库选项中的tortoisegit工具,它对我有用。
tried with tortoisegit tool from SVN repository option, its working for me.
我已经多次遇到这个错误
“revision argument: :HEAD not recognize by git-svn”
它通过增加修订限制的数量来工作
,例如 100 而不是 50
I have had the error several times
"revision argument: :HEAD not understood by git-svn"
it works by increasing the number of revision limits
for example 100 instead of 50