Cloning a Git SVN Clone
I’ve been trying to figure out a good way to make a publicly available
git-svn repo on GitHub.com that I can clone and then keep up to date with both the original svn repo and the GitHub repo and commit everything into my own fork.
So, how do you go about creating a Git repo that can push and pull to and from both Git and Subversion?
Clone the public repo
git clone git://github.com/drnic/ruby-tmbundle.git Ruby.tmbundle cd Ruby.tmbundle/
Fork the repo. optional
git checkout master git remote rm origin git remote add origin firstname.lastname@example.org:subtleGradient/ruby-tmbundle.git git pull
Set your subversion remote
Run this to set your subversion remote and pickup all your existing history asif you’d done a
git svn clone ....
git branch macromates git checkout macromates git svn init https://macromates.com/svn/Bundles/trunk/Bundles/Ruby.tmbundle -R svn cp .git/refs/remotes/origin/master .git/refs/remotes/git-svn git svn fetch
This should give you…
... r9048 = a0bdcedd42f7ed1867d32120bbf92bab7b72f085 r9051 = 4eb5fee1621549f676f9d5e085f1ccf03489e334 r9362 = 28b1ea1529b071fa10ba458e816e4a9454f85d8a Done rebuilding .git/svn/git-svn/.rev_map.dfb7d73b-c2ec-0310-8fea-fb051d288c6d
If you get this error…
Remote ref refs/remote/git-svn is tracked by "svn-remote.svn.fetch=:refs/remotes/git-svn" and "svn-remote.svn.fetch=:refs/remotes/git-svn" Please resolve this ambiguity in your git configuration file before continuing
… then you probably ran
git svn init twice without passing in a new name for each one. You’ll have to remove the extra
fetch = :refs/remotes/git-svn reference if your
Fetch from your public subversion repo…
git checkout macromates git svn fetch svn
Pull from your public Git origin…
git checkout master git pull origin master:master
Now you have two branches in the same Git repo that pull from a separate SCM.
Congrats, you so totally rock!
Once you’re done setting up and fetching changes from subversion, you should switch back to your
git checkout master
Next time… fetching, merging and pushing back!