Using Git with a Subversion Repository

Using git bash with a subversion repository is very easy when you know how to use it!

First, you’ll want to head over to the Git Website and get the latest release of the git application (we’ll be using git bash)

NOTE: when you install, consider checking “Git Bash Here” as a context menu option:

After it’s installed, go ahead and open git bash and cd to a directory where you want to download the repo to, or if you chose to install that context menu option, navigate to your folder in explorer (or finder) and right click on it then “Git Bash here”.

After that go ahead and run the “git svn clone” command on your repo, example:

git svn clone

Alternatively, you can clone a subdirectory of the svn repository by simply writing the directory name at the end of the repo address. This is particularly useful when you’re working on a large project and don’t want to download all the files on the server.

git svn clone

After you run the command you’ll be prompted for authentication, go ahead and fill that out and your repository will be downloaded onto your machine.

From there you’ll be able to modify the code, or whatever it is as you would regularly, then when you are ready to push changes back to the server, all you have to do is add these changes, and get them ready for commiting.

To start, go ahead and run this command:

git status

That should list out all the files you’ve modified, added, or deleted.

To track these changes run the add command:

git add .

The “.” at the signifies that you would like to track all the changes that were made. Another thing to note is that if you deleted a lot of files you would want to run the add command with another optional parameter:

git add -u .

This should track all the changes made, regardless of deleted, added, or changed.

Once you are satisfied you will need to make a commit to your local git repository by running the git command:

git commit -m "Your message goes here!"

Something to note about the commit command: You don’t have to use the -m parameter, it’s just that it’s much easier to do this, rather than being taken to a command line text editor to write a message.

Once you’ve commited your changes to your local git repository, you’re ready to push them to online subversion repository!

When pushing your git changes back to the online repository, you’ll want to run the subversion rebase command. What this command does is download all the changed files from the repository. You won’t be able to add your changes to the online repository if you don’t do this:

git svn rebase

After you’ve run that command, the only thing left is to commit those changes to your online svn repository:

git svn dcommit

And, that’s it! You’ve successfully learned to use the git bash with a subversion repository!

One more thing to note if you work on multiple machines. If you’ve cloned your repository on multiple machines you’ll need to run the rebase command:

git svn rebase

to download any changes from the server that you’ve commited from your other machine BEFORE you start working on your code on your current machine.


Now you’re ready to get working with git on your subversion repositories!

Leave a Reply

Your email address will not be published. Required fields are marked *