Git svn clone:如何推迟获取修订历史记录
我经常遇到这样的情况:我想立即使用 SVN 存储库。但是普通的 git svn clone [url] 也会克隆整个历史记录。所以我想加快速度。第一部分是仅将最后一个修订版本提取到 Git 存储库中。我这样做:
URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print $2}'`
PROJECT_FOLDER=google-web-toolkit-readonly
git svn clone -r$REV:HEAD $URL $PROJECT_FOLDER
(StackOverflow文章中的更多信息:“如何 git-svn 从 svn 克隆最后 n 个修订”
这样我就可以启动并运行并且可以立即工作。但是没有历史记录的本地副本。
问题是,之后我如何从 svn 存储库获取历史记录?
最好可以分块完成,比如 1000 个修订(按相反的顺序)。
I often have the case that I want to work on a SVN repository right away. But an ordinary git svn clone [url]
also clones the entire history. So I want to speed things up. The first part is to fetch only the last revision into your Git repository. I do it like so:
URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print $2}'`
PROJECT_FOLDER=google-web-toolkit-readonly
git svn clone -r$REV:HEAD $URL $PROJECT_FOLDER
(more info in the StackOverflow article: "How to git-svn clone last n revisions from svn"
This way I'm up and running and can work immediately. But without local copy of the history.
The question is, how do I afterwards fetch history from the svn repository?
And preferably, can this be done in chunks of, say 1000 revisions (in reverse order). Any help here would be greatly appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现了如何做到这一点。诀窍是不要使用
git svn clone
。相反,单独使用 git svn init 和 git svn fetch 。修改了例子:I found out how it can be done. The trick is not to use
git svn clone
. Instead, usegit svn init
andgit svn fetch
individually. Modified the example:所有建议的答案都不起作用。带有修订版的 git svn fetch 只会检索比已克隆版本更新的修订版。您也许可以使用 git svn reset 返回到较旧的版本并从那里检索,但是之后您必须做一些肮脏的工作才能将较新的版本“移植”回完整版本树(git 中 SVN 修订版的 SHA1 取决于修订版的整个出身)。如果您熟悉
git
为您提供的手术刀,那就去吧。避免这个问题要容易得多。
所以,这是部分答案 - 之后如何获取历史记录?将其获取到另一个存储库并复制您需要的内容。可以按相反的顺序以 1000 个为一组进行吗?有了手术刀和足够的耐心,它可以,但不太值得。向前运行的完整提取将超出您 git svn fetch 的每个块获取的所有第一个修订的开销,并且修复将变得乏味。
None of the suggested answers will work.
git svn fetch
with a revision will only retrieve newer revisions than what is already cloned. You may be able to usegit svn reset
to go back to an older revision and retrieve from there, but you'll have to do some dirty work afterwards to 'graft' your newer revisions back onto the full tree (the SHA1 of an SVN revision in git depends on the entire parentage of the revision). If you're handy with the scalpelsgit
offers you, go for it.It's much easier to just avoid the issue.
So, that's a partial answer - how can you afterwards fetch history? Fetch it into another repo and copy what you need over. Can it be done in chunks of 1000 in reverse order? With the scalpels, and a lot of patience, it could, but it's unlikely worth it. The full fetch running forward is going to outrun the overhead of all those first revisions grabbed by each block you
git svn fetch
, and the fixup will get tedious.git svn fetch
似乎“记住”了之前看到的修订版本。我在做范围方面取得了成功:我获取了最新的修订,然后开始“填补”空白。看起来效果很好。
Jesper —— 如果您的存储库没有修订版 1000,那么它就无法获取任何内容。确保您使用的修订号有效!
git svn fetch
appears to "remember" the revisions it's seen previously. I've been having success with doing ranges:I fetched the most recent revisions and then started "filling in" the gaps. It seems to work fine.
Jesper -- if your repository doesn't have a revision 1000, then there's nothing for it to fetch. Make sure the revision numbers you're using are valid!