A Workflow for Using Git to Track SVN Repository
16 Apr 2015Version control system is a complex issues, and hard to understand the idea of branching and different types of merging. I merely understand the basic of Git, and it already makes my life a lot easier, I am managing about 10 repositories at this moment without much effort.
But my collages are using SVN as the centre storage for scripts. Switching to SVN is not a problem, I just need few weeks to transfer the knowledge and start to use it. I am reluctant to learn something basic and have duplicated knowledge, also, I use GitHub and Bitbucket which are Git based. But sticking to Git make mine work impossible to work with collauges.
Then I found out the Git developer has already made effort to bridge Git and other version control system, like SVN. The git svn
allows me to just Git commands for staging, cherry-picking, pull etc, and then upload to the SVN remote repository with just one command line. I really like the idea of transferring the skills from one system to another without any cost, it makes me believe Git is great and I can continue to use Magit in Emacs!
Here is the basic steps and comments for this work flow:
- Create a folder
mkdir ProjRepo
- Create an empty Git repository
git init
- Add the following to
.git/config
and change the URL to right repository,
- pull from SVN central repository to this folder,
git svn fetch svn
- switch to SVN remote branch,
git checkout -b svn git-svn
- modify or add files
- use
git add
andgit commit
for snapshot local changes - sometimes need to update local repository,
git svn rebase
- finally upload local changes to SVN central repository
git svn dcommit
See the official manual 8.1 Git and Other Systems - Git and Subversion git-svn documentation for more details.