GitHub SVN Upstream (on Ubuntu12.04)

1 minute read

This is a git tutorial, create svn upstream on GitHub.
Use MOC project as a example.

#Checkout SVN and push to GitHub.
Install packages

$ sudo apt-get install subversion git-svn

Create git repository (it will take a long time)

$ git svn clone svn:// --no-metadata ./moc-svn-git  
$ cat moc-svn-git/.git/config  
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        noMetadata = 1
        url = svn://
        fetch = :refs/remotes/git-svn

Update SVN repository

$ git svn fetch
$ git cehckout remotes/git-svn -b svn-upstream  

Creat repository on GitHub

$ cd moc-svn-git  
$ git svn show-ignore > .gitignore  
$ git add -f .gitignore  
$ git commit -m "Convert svn:ignore to .gitignore"  
$ mkdir ../moc-bare  
$ git clone --bare ../moc-bare  
$ cd ../moc-bare/
Create empty repository on GitHub. (named moc-git)  
$ git push --mirror'your-account'/moc-git.git  

After this step, we create two folders.
moc-svn-git: SVN and Git Workspace.
moc-bare: Git bare for GitHub.

#Add GitHub repository to workspace

$ cd moc-svn-git  
$ git remote add github-moc'your-account'/moc-git.git  
$ git remote update  
$ git branch -a
* master

$ git checkout remotes/github-moc/master -b github-moc
$ git branch -a
* github-moc

#Merge upstream

$ cd moc-svn-git
$ git pull 
fetch remotes/git-svn
$ git svn fetch
$ git checkout remotes/git-svn -b upstream-now
$ git checkout master
$ git merge upstream-now
Fix Conflicts...
$ git add .
$ git commit
$ git push

Converting a Subverion repository to Git
Git SVN Tutorial

Leave a Comment