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.
# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...
No interaction between them. Just ignore the . git folder for SVN and the . svn folder for Git and you should be fine.
The git svn clone command transforms the trunk, branches, and tags in your SVN repository into a new Git repository. Depending on the structure of your SVN repo, the command needs to be configured differently.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With