mBerube.net
A journey to .Net

From SVN to GIT

Wednesday, 21 July 2010 15:07 by mBerube
(Also available in: français)

As you already know if you read that blog as religiously as you should, I’ve setup a dev server for my experiments at home. I’m using Visual SVN server as my source control tool but I work more and more on my laptop now and from many places where I don’t necessarily have a WiFi access.  It means that I can spend many days with uncommitted changes of my programs and I don’t like it because it’s really a pain to undo some work. I heard many times about Git which is a distributed version control system and allow you to have a complete repository locally on your computer. You can do many commit, branches and merges on your local repository and when you can connect to your remote repository, you can then push the changes so the others developers can use your updated version of the code. You can also pull the code for the remote repository to update your local copy of the code.

What is best for a Subversion user like my, is that you can still use Subversion as your remote repository and use Git as your local repository. That’s what I’ve tried and here’s the steps I took to go from svn to Git on my Windows 7 machine and to integrate all this in Visual Studio.

First, you must download the installer for Git and install the package. Make sure to check the Git Bash and Git GUI windows explorer integration, it’s really useful. Git Bash is really useful for all administrative tasks in Git. Git GUI is supposed to help with commit and branching but I preferred the Git extensions for Visual Studio for these tasks. More on this in my following posts.

Now that you have that, you can clone your Subversion repository locally. Using Git Bash, navigate to the folder where you want to create your repository and use the following command :

git svn clone –s https://mysuberversionserver/svn/myrepository/trunk

Of course, your replace the URL by your subversion project URL. At this stage, it’s recommended to set your .gitignore file. This file contains all the files and directories that you’ll want to exclude from git version tracking. There’s a lot of pages on the web about how to setup your .gitignore file so I wont give any specific details here (also, mostly because git extensions for Visual Studio contains a default template for .Net developer that already exclude all the temp file that doesn’t belong in the source control).

You have created your local git, now bring back the source from your svn :

git svn fetch

Your only need this the first time to create your first copy. After that, you’ll only do updates of the files. It’ll be a lot faster. You can start to do some changes locally and as you work, git will track all the files that are modified. When you’re done, you can use the commit command to post your changes on the local repository :

git commit

There’s many switches to the commit command. I’ll not mention all of them here but there’s a good one to check what will be committed without doing it:

git commit –v –dry-run

When you’re ready to push your changes to the remote svn repository, you can use the following command:

git svn dcommit

Here again, there’s a really useful command to check what changes will be push on the remote svn repository before doing it. It will show the name and the status of all the local files that are different from the remote repository:

git diff ..remotes/git-svn --name-status

You can finally get the changes from the other contributors on the remote repository by using :

git svn rebase

Ok, that’s it for the git svn quick tutorial. In the next post, I’ll talk about the Visual Studio extensions you can use to simplify the common tasks with git. I’ll also talk about branching with git and about some customizations you can do to speed up your workflow.

Thanks, happy developing

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Git | Programmer life
Actions:   E-mail | del.icio.us | Permalink | Comments (11) | Comment RSSRss comment feed

Comments

05 September 2011 16:08

Johnny Smith

Extraordinarily informative cheers, It looks like your trusty subscribers will probably want even more information similar to this carry on the great content.

Johnny Smith United States

13 November 2011 21:03

Crunchtechnica

Just wish to say your article is as astounding. The clarity in your post is just spectacular and i can assume you\\\'re an expert on this subject. Well with your permission allow me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the enjoyable work.  Thanks !

Crunchtechnica

30 November 2011 02:06

Dunia Digital

nice info you got here mate.. keep the nice blogging..

Dunia Digital Canada

05 December 2011 09:16

Electronic Circuit Diagram

Great blog, bookmarked for later use. thank you.

Electronic Circuit Diagram United States

30 December 2011 00:50

Cammie Damas

The best exercises for women over 50 are exercises you will do. Any and all movement counts! Get over the idea that you are too old to take a ZUMBA class.

Cammie Damas United States

10 January 2012 14:51

coachella

Suppose it's a useful post indeed! Just bookmarked it!

coachella Dominican Republic

12 January 2012 20:58

Lilian Starr

That thing does't want to stay one place.

Lilian Starr United States

18 January 2012 00:07

Cole Conca

I am not real excellent with English but I line up this rattling easy to interpret .

Cole Conca United States

21 January 2012 04:50

Lauri Lafreniere

Awesome article!! We have weekly email campaigns that ask the email recipients<br />to take action. Now, we shall be able to track their action easily!!

Lauri Lafreniere United States

22 January 2012 11:32

Neomi Rud

UPDATED CAR LIST 18th October 2011  ADDED Nissan Skyline 2000GT-R (C10)

Neomi Rud United States

02 February 2012 16:14

Esther Walstrum

Nice analysis and comparison to these group of films and the heyday of American Cinema in the 1970s. Good choices in your Top 10 (particularly "Drive," "Martha Marcy May Marlene" and "Young Adult") but "The Descendants?" Really? I think its easily the weakest and most pat of Alexander Payne's films and in year filled with extremely interesting films and was surprisingly superficial. Otherwise good job (though maybe you could have put in "Tyrannosaur?")

Esther Walstrum United States

Add comment




  Country flag

biuquote
Click to change captcha
  • Comment
  • Preview
Loading