jump to navigation

Import Git to Subversion October 6, 2009

Posted by maxmil in : git , 3 comments

There are lots of docs out there for how to use git-svn starting with a subversion repository that already exists, however not so many if you are starting with a git repository that you want to import into subversion.

I still consider myself a beginner with git but here is how i managed it.

1) Create and import an empty subversion repository.mkdir tmp
mkdir tmp/my-project
mkdir /my-project/trunk
mkdir /my-project/tags
mkdir /my-project/branches
svn import tmp http://some/svn/repo -m "Initial import"

2) Clone a git repository from the subversion one you just importedgit svn clone -s http://some/svn/repo/my-project(The -s tells git svn that you are using a standard layout for branches, tags and trunk).

3) Enter your new svn enabled git repositorycd my-project
4) Add your working git repository as a remote repository.git remote add dev /path/to/working/git/repository
5) Pull all the commits from your working git repository into the master branch of the new repostory.git pull dev master
6) Rebase these commits ontop of the initial svn commit.git svn rebase
7) Commit changes to svn.git svn dcommit (Note that you can use the -n option to check first the commits that are about to be committed).

And that should do it, you can now remove the remote repository dev from your new svn enabled repository and carry on working using git svn dcommit to push local changes to the subversion repository.

GIT: Setting up new remote repo August 28, 2009

Posted by maxmil in : git , add a comment

This is quick reminder for me of an excellent article from Toolman Tim.

Set up the new bare repo on the server:
$ ssh myserver.com
Welcome to myserver.com!
$ mkdir /var/git/myapp.git && cd /var/git/myapp.git
$ git --bare init
Initialized empty Git repository in /var/git/myapp.git
$ exit

Add the remote repository to your existing local git repo and push:
$ cd ~/Sites/myapp
$ git remote add origin ssh://myserver.com/var/git/myapp.git
$ git push origin master

Set the local master branch to track the remote branch. Copy the following into ./git/config

[branch "master"]
remote = origin
merge = refs/heads/master