Well just as it was previously obvious that we needed to switch from CVS to Subversion, I'm starting to get a similar feeling with switching from Subversion to Git. So we are now interested in the possibilities of hosting private repositories in Bitbucket. We aren't experts in the GIT ecosystem and we run windows throughout here. Because of this I want to start with baby steps. I figured a good start would be to just get one of our internal repositories out into Bitbucket so the following are the steps I took (minus the many hours) to do just that.
Notice: I'm assuming there are many ways to do what I was trying to do. This is just the way I did it :) Also, these steps are unfortunately not complete. I did not record everything that I did here. I just had some notes after my success and thought I would share.
Step 1- Install Git for Windows
Step 2- Install Ruby
Step 3- Install the Ruby gem svn2git
gem install svn2gitThat should do it. I looked into other tools that supposedly migrated Subversion repositories to Git but this one seemed the best for me.
I tried several times to get svn2git to work but just couldn't. Then I realized that git already has git-svn built into it so I should just use that! At this point I'm not even sure that we needed Ruby installed. Like I stated earlier, these steps aren't compete.
Step 4- Clone the SVN Repository using git svn
git svn clone -s https://server.local/svn/someProjectThis clones the SVN repository (including the trunk, tags, and branches) into the directory you are in. The -s flag states that the repo structure is in the standard format. Be warned that if you are cloning an old/active repository that this will take a long time to complete. I actually recommend doing this once and then making a copy of the resulting folder. This way if you end up messing up something in the clone (like I did several times) you can just delete it and use the copy you created instead of having to run this command again.
Note: If you have a repository that you just can't do a complete clone of because it is too big you can run the following command:
git svn clone -s -r HEAD https://server.local/svn/someBigProjectThe -r HEAD means to just grab the most recent version of the trunk so this will not include any history. If you do this then you can skip Step 5 below.
Step 5- Execute a Git Checkout
git checkout -b trunk remotes/trunkThis is needed because if you look at the folder that was created from the clone, you'll notice it is empty except for a .git folder. This command is checking out the trunk to the working tree. After this you'll see all of the code that was in your trunk.
Step 6- Change name of branch from trunk to master
git branch -m masterI don't think I had to do this but I thought it was a good idea as master seems to be the convention for Git.
Step 7- Update the Working Tree
git svn rebaseThe documentation states that this fetches revisions from SVN and "rebases" the current tree and that it is similar to an svn update. The thing is though is that when I did this I expected nothing really to happen because I just pulled from svn and there weren't any commits to it but for some reason this acted like it was doing a bunch of modifications.
Now things get even weirder. I ran the same command again:
git svn rebaseThis seemed to do even more updates and took a little bit of time to complete. At this point when I ran the same command again I received the following response:
'Current branch trunk is up to date.'That's what I was expecting the first time I ran that command. I don't understand but this is what worked for me.
Step 8- Create a New Bitbucket Repository
Step 9- Generate & Install SSH Keys
ssh -T email@example.comIf you receive a message similar to the following then you are good to go:
conq: logged in as gbrunton.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
Step 10- Prepare repository for Bitbucket
git remote add origin ssh://firstname.lastname@example.org/gbrunton/someProject.gitThis adds a remote for the repository. Whatever that means :) I noticed though that it updates the config file within the .git folder.
Step 11- Push to Bitbucket
git push -u origin masterThis command pushes the local repo into Bitbucket with all of the
Step 12- Schedule Daily Task