Git svn clone:如何推迟获取修订历史记录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1554222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:53:21  来源:igfitidea点击:

Git svn clone: How to defer fetch of revision history

gitgit-svnclonegit-clone

提问by Jesper R?nn-Jensen

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:

我经常遇到我想立即在 SVN 存储库上工作的情况。但一个普通人git svn clone [url]也克隆了整个历史。所以我想加快速度。第一部分是仅将最后一个修订版提取到您的 Git 存储库中。我这样做:

URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print }'`
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"

(StackOverflow 文章中的更多信息:“如何 git-svn 从 svn 克隆最后 n 个修订版”

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?

问题是,我之后如何从 svn 存储库中获取历史记录?

And preferably, can this be done in chunks of, say 1000 revisions (in reverse order). Any help here would be greatly appreciated :)

最好是,这可以分块完成,比如说 1000 次修订(以相反的顺序)。任何帮助在这里将不胜感激:)

采纳答案by Jesper R?nn-Jensen

I found out how it can be done. The trick is not to use git svn clone. Instead, use git svn initand git svn fetchindividually. Modified the example:

我发现了如何做到这一点。诀窍是不要使用git svn clone. 相反,单独使用git svn initgit svn fetch。修改示例:

URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print }'`
PROJECT_FOLDER=google-web-toolkit-readonly

mkdir $PROJECT_FOLDER
cd !$ #goes into dir named $PROJECT_FOLDER
git svn init -s $URL #-s implies --stdlayout with /trunk /tags /branches
git svn fetch -r $REV

# hack, hack, hack

# or update history (fetch 50 revisions back each loop
for (( r=$REV; r>0; r-=50 )); 
do 
  git svn fetch -r $r:HEAD
done

回答by Chris Nash

None of the suggested answers will work. git svn fetchwith a revision will only retrieve newer revisions than what is already cloned. You may be able to use git svn resetto 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 scalpels gitoffers you, go for it.

所有建议的答案都不起作用。git svn fetchwith a revision 只会检索比已经克隆的修订版更新的修订版。您可能可以使用git svn reset返回到旧版本并从那里检索,但是之后您必须做一些脏活才能将您的新版本“嫁接”回完整的树(git 中 SVN 版本的 SHA1)取决于修订的整个出身)。如果您对git提供给您的手术刀很方便,那就去做吧。

It's much easier to just avoid the issue.

避免这个问题要容易得多。

  • Do an initial clone of the last few revisions, so you can get working immediately;
  • Start another clone of the full history into another directory/git repository;
  • Work in your partial history as much as you want;
  • When the full clone completes, use an approach like http://www.sanityinc.com/articles/relocating-git-svn-repositories/to copy your work from the partial repository to the full one.
  • 对最后几个修订版进行初始克隆,以便您可以立即开始工作;
  • 开始另一个完整历史的克隆到另一个目录/git 存储库;
  • 尽可能多地处理你的部分历史;
  • 完整克隆完成后,使用类似http://www.sanityinc.com/articles/relocating-git-svn-repositories/的方法将您的工作从部分存储库复制到完整存储库。

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.

所以,这是一个部分的答案 - 你之后如何获取历史?将它提取到另一个 repo 中并复制您需要的内容。可以以相反的顺序以 1000 块为单位完成吗?用手术刀和很大的耐心,它可以,但不太值得。向前运行的完整提取将超过您每个块抓取的所有第一个修订的开销,并且修复git svn fetch将变得乏味。

回答by Rob Crawford

git svn fetchappears to "remember" the revisions it's seen previously. I've been having success with doing ranges:

git svn fetch似乎“记住”了它之前看到的修订版。我在做范围方面取得了成功:

git svn fetch -r 0:100
git svn fetch -r 100:200
git svn fetch -r 4500
git svn rebase
git svn fetch -r 200:300

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!

Jesper——如果您的存储库没有修订版 1000,那么它就无法获取任何内容。确保您使用的修订号有效!