In the previous post,
Pulling a Subversion Repository into Git Locally, I shared the process that I went through in order to pull Subversion into Git so that I can start using Git locally with Subversion as my remote repository. Since that time, I have been trying to figure out the best way to get Git to Subversion repositories set up for others on my team. I have gone through a lot of trial and error and now I believe that I have finally come up with an easy step-by-step solution.
Before I begin, let me first say that you probably want to follow these instructions for two main reasons:
Cloning a Subversion Repository is very time consuming
If you have never cloned a Subversion repository using Git, you will be amazed at how long this process can take (depending on how much history you want in Git). I typically chose 1000 revisions in the past, and that could take up to an hour or more. This is no fault of Git, instead, Subversion is to blame. With this process, only one person has to incur that time investment. Everyone else, can just reap the benefits without the hassle
Fetching too much data
This was the problem that has stumped me for months. While I was able to alleviate the first challenge of the time investment for everyone, I could not figure out why Git was trying to retrieve so much history from Subversion. This amount of history was even earlier than the 1000 revisions of the initial clone. Finally, I figured out that it has to do with a property called
branches-maxRev. Through the use of this property, we can make sure that when you perform
git svn fetch, that it will not attempt to retrieve any more history than necessary. So, let's get started
By this time, I am already assuming that you have followed the directions from
Pulling a Subversion Repository into Git Locally, and you already have a Git repository with the amount of history from Subversion that you desire. From that point:
- Navigate to your git repo. Not the .git folder, but the folder containing that folder
- Open your browser to the git svn man page
- Scroll to the bottom section titled Basic Examples, and look at the third example
- Locally, start the git daemon server by typing: git daemon. This will start a git server on your local machine that will allow others to pull from you.
- Follow the instructions from the Basic Example starting with mkdir all the way to the end. Please note that the line that section that says server:/pub/project must be replaced with a valid git url (for instance git://jdcarlflip.blogspot.com/path/to/git/repo)
- Once you have finished those instructions, in your newly created repo, open the file .git/svn/.metadata
- Inside of there, you want to put a line under the uuid similar to the following branches-maxRev = 11111 where 11111 is the revision number that you do not want to go past. If you don't know what to put in there, look back at your original repo that you cloned from, and use the same number.
- After you have done this, type in git svn fetch, and it should not attempt to retrieve any revisions that are older than the ones you have already
If there are any questions, please let me know.....Enjoy.