mBerube.net
A journey to .Net

Integrating Git into Visual Studio 2010

Saturday, 24 July 2010 00:10 by mBerube
(Also available in: français)

In the previous post, I talked about Git, a distributed version control system. The classic way to use Git is to use the bash command line. But if you use Visual Studio, you have some extensions you can use to integrate all the goodness of Git into your favourite IDE. Although I still need the command line tool to do some tasks like doing rebase and dcommit on the subversion server, most of the things you need during development are available in your IDE.

Git source control provider

This extension (downloadable from the visual studio extension gallery) set Git as your source control provider. This tool is pretty limited but have 3 interesting features :

  • It displays the name of the current working branch at the top of the solution explorer
  • It shows the status of the files in the solution explorer (added, modified or unchanged)
  • It give a shortcut to open the Git bash windows in a specific solution folder

git source control provider

This extension by itself give really basic functionalities but with the addition of the git extensions for visual studio, it becomes more interesting.

Git Extensions

This extension can be downloaded from Google code and add many Git commands into Visual Studio and Windows Explorer. You can see in the picture above that Git source control provider include a shortcut for Git Extensions but you can use it by itself.

In Visual Studio, Git extensions add a new tool bar and a new menu into the IDE. By these menus and toolbars, you can do much of the day to day work with Git (you can see the new tool bar in the red circle).

git extensions menus

To be honest, I don’t know yet what all these options do but here’s a quick explanation for some of them :

  • Checkout branch : switch from the current branch to another branch. More details on this in a following post.
  • Commit : commit the change in the current branch to the local repository. See below the picture of the commit window.
  • Edit .gitignore. Allow you to set the .gitignore file for your local repository. You can do it manually but if you’re a .Net developer, I suggest you take the default template for .Net that exclude all the temp files. So far, I don’t find any missing files or files that should be exclude.
  • For all the remote features (Manage remotes, pull, push, rebase, etc.), I didn’t try them yet because I never used a remote Git repository for now.

Some more explanations about the commit process. When you want to commit something, you open the commit window :

git commit window

In the top left part, you select the files you want to commit and you click "Stage selected file” to include them in the commit. You must enter a comment in the right bottom section and click “Commit” to confirm. If the file has a change status “Untracked”, it means it’s a new file and the code part (top right) will show the source code. If the status of the file is “Modified”, the code part will show a diff between the 2 versions. Really useful. If you want to rollback a change to the previous version, select the file(s) to want to be rolled back and click “Reset changed”.

I think that’s enough for now. Next post, I’ll talk about branching and merging with Git, with both Git Bash and Git Extension.

Thanks, happy programming.

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 (0) | Comment RSSRss comment feed

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 (0) | Comment RSSRss comment feed

Access machine by hostname between Linux and Windows without DNS server

Wednesday, 23 June 2010 12:39 by mBerube
(Also available in: français)

During setup of my Dev server, I found that I was able to access my Linux server by IP but not by name. The same thing was true from Linux to Windows. After a couple searches on the net, I realized that my network wasn't using a DNS server. It means that the name solution was made by another mecanism. In my case, my machine names are resolved using Netbios. So, how to make it works on Linux (specifically Ubuntu but it's pretty much the same for the other distrib I guest) :

  • Install samba (sudo apt-get install samba)
  • Once install, edit /etc/samba/smb.conf and, in the global settings section, set the workgroup and netbios name values to the proper values for your machine.

Your now able to access your Linux box by name from Windows. Now, how to do the other way (from Linux to Windows) :

  • edit /etc/nsswitch.conf and change the line hosts: file dns by hosts: file wins dns (order matters)
  • Finally, install winbind (sudo apt-get install winbind)

After that everything works as expected, from Windows and Linux. I hope it will works for you as well.

Be the first to rate this post

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

Starting a development server

Friday, 28 May 2010 20:18 by mBerube
(Also available in: français)

Hi

I'm a lot less involved in my blog for a couples weeks. Summer is coming and I also got a used Dell server, decommissioned by a company. That a good occasion to improve my sys admin skills and having a real development server.

I would not give all the details in that post but there's some situations I faced. For professional sys admin, all this is piece of cake but with my programmer background, many of these things were unknown to me just one month ago :

  • Installing et configuring RAID : the server has a Adaptec RAID card that I set for RAID 1 (mirror) and everything works, easily and quickly (but I still have some performance issue to check for later)
  • Installing an OS on DVD on a server with only a CD-ROM drive : here, new challenge. I could buy a DVD ROM and install it but I don't like really much working with fragile optical media so I looked for alternatives and I found the procedure to format a USB thumb drive, make it bootable and use it to install the OS. For the details of that procedure, go to Technet. To install the OS (windows server 2008 R2), nothing special, except a bit of extra work to find the RAID card drivers. For the rest, it's almost the same as intalling Vista or Windows 7.
  • Partitions : I like having a partition for the OS and software ande another one for data. I forgot to do it before installing windows server but the Disk Manager is awesome. You can resize a partition like Partition Magic does but you can also do it live, on the OS partition, with the server running. Wow !
  • RAM Upgrade : the machine came with 1GB of RAM. It was a bit low for the tasks I want this machine to accomplish (see below). I bought 2x2gb ram in my favorite computer parts retailer. I was wrong. I learned (the hard way) that server are more specific about the kind of ram they support. I finally found a supplier for the right kind of RAM I needed (it cost me a little more but not much) and now my server have 5gb of ram, enough to do what it needs to do.
  • The softwares:
    • SQL Server : I has never install the full version of SQL server before (by that, I means, not the Express version). It's a bit more complicated than express, there's many service accounts to create and I didn't help myself by putting the database files at the wrong place but I finally make it works. Remember to setup TCP access to SQL server to allow connection from another machine.
    • IIS 7.5 : easy to install and with a little add-on (IIS Management Console), you can manage the IIS server completely from the IIS on your local machine. Nice.
    • VisualSVN Server : the simplest way to setup a Subversion server. It's a little (and free) tool that you install on windows and that simplify all administrative tasks of a source control. On the dev machine,  TotoiseSVN is a must.
    • Vmware server : my server is too old for the Microsoft virtualization technology (Hyper-V) so I installed Vmware Server. It's not really complicated to install, you use a Web interface to administer your virtual machines. It make administration easy and portable but the web application have somes bugs. I also have difficulties installing properly Ubuntu server (I'm at my 3rd attempts) for PHP and Ruby development. I'm still working on this.

That's it. This is where I spent most of my free time for the last weeks so you understand why my blogs isn't as active as it could be. I keep you informed.

Be the first to rate this post

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

Windows Home Server for developer

Thursday, 22 April 2010 22:47 by mBerube
(Also available in: français)

Last year, after the good comments of Scott Hanselman, I decided to try Windows Home Server, a light version of Windows Server 2003. It's a really integrated OS that allow easy file sharing between all home PC (music, photos, videos), easy and complete backup of all the connected machines and allow to backup all this on an external drive to put in a safe place in case the server is destroy, lose or stealed.

I installed it on a old machine (a 10 years old AMD athlon) and it worked pretty well (but I had some stability problem, mostly caused by aging componants). Also, I began to run out of space and IDE HD are hard to find and cost more than SATA. So, I decided to use a real WHS solution, the Acer Aspire Easy Store Home Server:

I used it for a week now and everything is fine. The transfer was very long (400 gb on a 100mb network takes time), that's a really quiet machine, thanks to Atom processor that consume less energy and runs cooler.

WHS come with a connector that allow basic administration of the machine. It gives access to all operations a home user requires. (BTW, MS sells WHS as a simple consumer product that everybody can setup. FALSE. You need some basic knowledge in Windows Security and networking. Geek required !).

It's also a product that can be really useful for a small developers team because WHS allow sharing and backup for up to 10 PC. As a dev, you surely know how to use RDP so you can connect directly to the box and do almost anything you can do in Windows Server 2003. Beware because WHS use a technology called Drive Extender that create a kind of "raid" where all the disks are added and shown as a big storage space:

Dont' use tools like that manage disks (disk management, RAID controller, defragmenter), let WHS do it and use shared folders to transfer your files.

There's 2 interesting things to do with your WHS:

  • WHS allow remote access to files using a web interface. You'll then see that IIS (6.0) is installed and fully functional on the machine and makes it a really good candidate for QA web site before putting them in production. If you need database, I installed SQLServer 2008 Express without problem.
  • That's also a really good place to put your source code repository. Personally, I use Visual SVN to manage my repositories and I've included them to a shared folder (that is included in my backup) so my SVN database is automatically included in my weekly offsite backup. Really great !

Finally, there's many Add-ins availables, mostly on We got served to add more cool features to your server. It's an interesting product and it relatively low price (less than 400$, OS included), makes it a simple and cheap solution for home and work.

P.S : I don' receive anything from MS to comment that product, I'm just a enthousiast user !

Be the first to rate this post

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