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

发布于 2024-08-06 23:50:36 字数 646 浏览 11 评论 0原文

我经常遇到这样的情况:我想立即使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情深如许 2024-08-13 23:50:36

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

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

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

URL=http://google-web-toolkit.googlecode.com/svn/trunk/
REV=`svn info $URL |grep Revision: | awk '{print $2}'`
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
憧憬巴黎街头的黎明 2024-08-13 23:50:36

所有建议的答案都不起作用。带有修订版的 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 use git 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 scalpels git offers you, go for it.

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.

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.

初见终念 2024-08-13 23:50:36

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

我获取了最新的修订,然后开始“填补”空白。看起来效果很好。

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

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

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文