开发者

Tracking a large project that has switched from svn to git

I'm tracking a project that has recently moved from svn to git. I've got the most recent svn code and want to start using the code from git. Is there a way to do this that doesn't involve re-downloading quite a large codebase over a slow connection? Essentially, I want to be able to say "start from here (开发者_StackOverflow社区old svn code) and just get the changes from git".


SVN & Git may seem similar because they're both SCM tools, but under the hood, they're implemented very different, i.e. Git is way better.

Just start from fresh and git clone it. Even for large projects like the Linux Kernel, Git is very fast at cloning.

You could also use the --depth option to speed things up:

--depth <depth>
Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

Source: http://git-scm.com/docs/git-clone

Here's an example that checks out the most recent version of the repository:

git clone git://source.winehq.org/git/wine.git ~/wine-git --depth 1

Source: http://mortalpowers.com/news/speed-up-git-clone-with-shallow-clones

You can later use the --depth option with git pull:

--depth=<depth>
Deepen the history of a shallow repository created by git clone with --depth=<depth> option by the specified number of commits.

Source: http://kernel.org/pub/software/scm/git/docs/git-pull.html

Perhaps, if you put a large enough number (or maybe -1?) for depth so as to pull in the entire history of the repository, then you'll have all the functionality of a normal repository, e.g., the ability to clone or fetch from it, or push from or into it.

If not, you can just clone it normally in a separate place (perhaps when you have a faster connection) and use git format-patch and git apply to move your commits from the shallow repository into the new one.

Matt


I think you need to clone the project anyway


The problem in this case is, that git doesn't just saves the latest checkout, but the whole history of the program (all commits, tags, branches, whatever), so you can easily switch between different revs. Thus, the latest checkout is not saved anywhere - it's just ad-hoc generated from the data.

But if you want to save bandwidth, AFAIK there's an option to just download all objects beginning by a given date, just google a bit or search SO to find out the name (I forgot it). The obvious disadvantage from this is, that any history before this point isn't available. But for simple tracking, it may be sufficient.


You may be able to save some time by pre-seeding a git repository with what you've got already -- you'll probably still have to download quite a lot (and I'm not sure how clever it'll be at working out the minimum it needs) but it may help.

If you create a new git repository and add your subversion checkout to it, that repository should have many of the objects which would otherwise be downloaded. You can then clone the upstream git repository using your new repository as a reference:

git clone --reference /local/reference/repo git://remote/upstream/repo

Note that the new cloned repo will depend on the existence of your hacked one for objects; you can work around that by re-cloning the local repository.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜