Convert large SVN repo to Git

The procedure looks pretty straightforward and simple, however I encounter quite few problems and took me few hours to figure them out.

First Approach – git svn clone

git svn clone https:// <your svn repo> –username vincent.yang –trunk TRUNK –tags TAGS –branches BRANCHES

1. The –username parameter is optional in the above command, although –trunk, –tags and –branches are also optional from the git svn manual, but I do recommend you explicitly specify them respectively. I did encounter few different weird issues before I explicitly specify them.

2. Most of times, the command doesn’t work under my windows version’s git, I had to switch to MAC & Ubuntu.

Second approach – svn2git

svn2git https://<your svn repo>  –username vincent.yang –verbose –trunk TRUNK –tags TAGS –branches BRANCHES


Create new git repo from the existing repo

My company has their own bootstrap and requires every developer use this bootstrap when set up a new site.
Previously I was quite new to Git, so my temporary solution was clone the existing repo and update the existing remote url to the new repo url, then run the push command to import bootstrap code into new repo.
There is pro and con in the above method and sometimes make git newbie confused.
Pro: After push to new repo, you can work against the current directory directly.
Con: If you need to set up another site, you have to clone the bootstrap again into another new directory.
Today, after one hour research, I finally found a better way to achieve the same goal and make more sense to git newbie.
The following steps show you how to create a new git repository from the existing repository
  1. Create new repo e.g. RepoTest
  2. Clone the existing repo
  3. Run git push <your new repo url> master
  4. Clone the new repo and now you could start to work on it.

Git Command

My git knowledge base

List branch

Description Command
Local branch git branch
Remote branch git branch -r
All branches (include both local and remote branch) git branch -a

Create local branch and switch branch

git checkout -b feature1

Delete local branch

  1. switch to other branch or master first – git checkout master
  2. delete  the branch – git branch -d “local branch name”

Push local branch to remote server

git push origin feature1

Merge branch to master

  1. Switch to master
  2. git merge “your branch name”
  3. git push (push your merge to remote repository)

Update remote repository URL

git remote set-url origin git://

We probably will use this technique to set up a new project from the template.

  1. clone the template
  2. create new repository in stash
  3. update the git remote repository url to the new one created in step 2
  4. run push command which add template to the new repository
  5. check out the code from new repository and working on it.

Alternatively, we can add multiple remote repository in git config, need more investigation

Useful resources

Git simple guide