简体   繁体   中英

Cloning a git-svn repository with svn metadata

I've cloned my main repository with git-svn clone svn://url/trunk --stdlayout . Now I want to clone the repository, with the svn meta data. So that I'll be able to git-svn rebase it to the main server.

Note, I don't want to push commits between two git-svn clones, I simply want to add all the git-svn metadata to the newly cloned repository, so that the new clone will be able to communicate with the main subversion server as well.

It's in the docs . What you should do is:

git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
git fetch

to fetch the svn meta-branches. Then you'll be able to git-svn rebase without fetching everything from scratch.


Quoting from the docs:

The initial git svn clone can be quite time-consuming (especially for large Subversion repositories). If multiple people (or one person with multiple machines) want to use git svn to interact with the same Subversion repository, you can do the initial git svn clone to a repository on a server and have each person clone that repository with git clone:

# Do the initial import on a server
        ssh server "cd /pub && git svn clone http://svn.example.com/project
# Clone locally - make sure the refs/remotes/ space matches the server
        mkdir project
        cd project
        git init
        git remote add origin server:/pub/project
        git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
        git fetch
# Prevent fetch/pull from remote git server in the future,
# we only want to use git svn for future updates
        git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched
        git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
        git svn init http://svn.example.com/project
# Pull the latest changes from Subversion
        git svn rebase

Super-fast simple copy-clone between remote machines

From the docs :

'git clone' does not clone branches under the refs/remotes/ hierarchy or any 'git svn' metadata, or config. So repositories created and managed with using 'git svn' should use 'rsync' for cloning, if cloning is to be done at all.

A copy-clone on the same machine can simply be done using cp -rp <src> <dst> , and from a remote machine using scp -rCp <src> <dst> .

However, the remote case can be very very slow (10 minutes even on ethernet) because of the large number of tiny files it has to copy.

Using cpio you can avoid this overhead, meaning (depending upon bandwidth) it just takes a few seconds (for a 100Mb git repo on a 50Mbit/s connection).

ssh -C <user>@<host> "cd <path to parent dir of repo>; \
find <repo directory name> -depth -print | cpio -oa" | cpio -imd

For example

ssh -C alex@myhost "cd ~alex/repos/; \
find WonderProject -depth -print | cpio -oa" | cpio -imd

results in a new git repo 'WonderProject' in the current working directory on the local machine.


(note that the documentation I refer to almost denies the existence of the section @Elazar refers to, so I'm not discrediting @Elazar's excellent solution, but looking for a more concise memorable one)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM