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
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
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)