I’m sure it’s nothing earth shattering but I’m blogging this for myself as documentation. :)
I have MVC Turbine hosted out on CodePlex, which means I can either access the source via Team Explorer or the SvnBridge endpoint the site provides. After talking with some people yesterday during lunch, I decided to try this simple proof of concept: Accessing TFS with git via SvnBridge. Sounds crazy but it works…and here’s how.
Your favorite Git client
This works with either msysgit or cygwin with git installed. So pick whichever you want to use. :)
Clone your CodePlex SVN Repo
Using your favorite Git client, it is time to clone your SVN repo with git svn. For this example, I will use the SVN repo for MVC Turbine as sample repository. To keep things clean, I created a C:\git\codeplex folder using the command line:
Then I ran the git svn clone https://mvcturbine.svn.codeplex.com/svn/trunk mvcturbine command to initialize a git repository under the C:\git\codeplex\mvcturbine folder:
Since the certificate out in CodePlex is self-signed, you’ll be prompted to validate it. Since it’s valid and don’t want to get prompted again, select option (p):
From here, the cloning (checkout) of the repository will execute:
Adding files to the Repository
After the cloning (checkout) is complete, let’s add a new file called blogpost.txt via Git. Now, I won’t step you through the process of creating a new text file, so let’s assume it’s done and you’re ready to add the new file to your local Git repository. From here, you’ll want to run the git add . command to add the blogpost.txt file to the local Git repository. Once that’s complete, we want to commit the change to the local repository. To do so, run the git commit –m “Showing how to commit to TFS through SvnBridge and git-svn” this will add the message as part of the commit:
From here, you can edit/delete/add other files to your local Git repo. For this blog post, let’s say we’re all done and we will now push (svn commit) our changes to the TFS repository.
Committing to SVN Repository
Once we’ve added the file to the local repository, we can commit the change to the SVN repository by running the git svn dcommit command:
Here you’ll be prompted for your username and password. By default the commit uses the current username, in my case javier. However, my CodePlex username is jglozano. Once you’ve provided the right credentials, you’ll be able to commit.
After the commit is over you can check the CodePlex website to see if the changes took place:
Pretty simple, huh? (and kind of cool) :)
Happy Coding!