
Using Subversion and Git for the same working copy
How I handle a private working copy of a project with Subversion and publish the non-private parts with Git easily
Sep 7, 2018 · 2 min read
I have been using Subversion for my projects for more than 10 years. There is no reason to change this, but I wanted to publish some projects on GitHub, too. The GitHub repository should exclude private files which I want to hold in my local repository only. Recently I found a solution, that works well until now and that I want to present you here.
I describe my procedure from checking out a Subversion working copy to making a modified version as Git Repository in the same directory and publishing it on GitHub. Editing of the working copy will also edit the local Git repository with no additional work.
- I check out a Subversion working copy of a project that has to become a Git repository. Then the work with git and GitHub can begin. The next steps are done on the command line.
- I change to the directory of my Subversion working copy. There I call “git init". Now the Subversion working copy is also a local Git repository. With the command “git status” I get listed the files that can be added to the Git repository.
- I call “git add …”. The additional parameters are the files that will be part of the public GitHub repository.
- To exclude unwanted files in future automatically, I create the file “.gitignore” with all file name masks, that have to be ignored by git in future. The directory “.svn" should always be ignored.
- The file .gitignore has to be added with “git add .gitignore”. After another call of “git status" there should be no more files to add or ignore.
- I call “git commit" to update the local Git Repository.
- I use the web browser to create an empty GitHub repository with the same name as my local Git repository = Subversion working copy.
- I link my local repository to this new one on GitHub with the command “git remote add origin https://github.com/jakobsche/test.git"
- Then I push my local repository content to this related web repository with “git push -u origin master”.
- From now, the local copy can be handled like a clone of the web based repository.
- Finally, I add all new files and directories to my Subversion working copy and do a “svn commit". The result is, that the local Git settings can be stored in the Subversion repository and being checked out for future work around without to lose the connection to the GitHub repository. The working copy will always be a local image of the related GitHub repository.
