Kash Farooq's software development blog

.NET Developer

Posts Tagged ‘Git’

Getting started with Git Source Control (and carrying code around on a USB)

Posted by Kash Farooq on July 10, 2011

I’m just starting out with Git (on Windows), so I thought I’d blog about it at the same time.

I downloaded and installed the msysgit version from here: http://code.google.com/p/msysgit/downloads/list.

After installation is complete, create a directory for your source code and initialise a Git repository there:

md c:\dev\git-repo
cd c:\dev\git-repo
git init

Now, add some code/directories to c:\dev\git-repo.
You may also want to add a .gitignore file to exclude files you don’t want to check in: here is my .NET development .gitignore file.

When you’re done, add them to your Git repository and commit your changes:

git add .  <-- this adds all files beneath this level. Hence why you may want a .gitignore file.
git commit -m "Initial commit"

Now, so that you can carry your code around on a USB drive, do the following (where g: is my USB drive):

md dev
cd dev
git clone --bare c:\dev\git-repo

You’ll see a message like:

Cloning into bare repository git-repo.git...

The “bare” command leaves you with a Git repository without your files and directories. If you want to work on them you need to do the following (on say, your other computer):

md dev
cd dev
git clone G:\dev\git-repo.git

Note: the last git clone was without the “bare” command – so your files will get extracted out of your USB repository and are available to work on.

Posted in Git Source Control | Tagged: , | Leave a Comment »

Git: Ignoring files for .NET development

Posted by Kash Farooq on July 10, 2011

Here is the .gitignore file I use for .NET/C# development. Add this file to the root of your Git repository so you don’t end up adding ReSharper files, bin folders, etc to your commits:


Posted in Git Source Control | Tagged: | Leave a Comment »

Bazaar or Git? Moving away from Subversion.

Posted by Kash Farooq on September 8, 2009

I’ve had enough of Subversion and decided to move to Bazaar. Click BZR in the Tag Clould to see my series of blog posts to help you do the same.

Do any of these Subversion complaints sound familiar?

  • You are randomly instructed that “you need to run update”. You then do an update – which takes ages to complete. And then, finally, you see that there were no changes that needed to be downloaded.
  • You are randomly instructed that “you need to run cleanup”.
  • You have huge merge problems. For example, you use ReSharper to rename a class, and some else has updated that class in the meantime. You then see the dreaded tree conflict error (shudder). Or even worse, you rename an entire namespace and folder (double shudder). Now you really are in for a world of pain.
  • Your merges tend to be more and more manual. You frequently have to use WinMerge because Subversion hasn’t got a clue.
  • You are often waiting around for Tortoise to update/check for modifications/anything.

I have a subversion repository on my USB pen drive. I get tree conflicts and merge problems with that, and I’m the only user!

The main problem is merging. Our team has to work on branches as we have different projects running concurrently, working on the same code base. We don’t know which project will be going live first, or even if the project will be released at all (they may get canned). So, we need an efficient merging process.

Merging has become so problematic that we’ve considering adding merging as a separate task for each MMF we implement – that’s how long it takes nowadays. We’ve even considered putting a “Work In Process” limit on particular pieces of code to make sure two unrelated MMFs don’t touch the same code.

[Can you tell that I am not happy with Subversion?]

So, I decided to try something else.

I was going to try Git. I downloaded binaries, documentation and guides. But then I read this article: Renaming is the killer app of distributed version control. And I agree, renaming is really, really important. We rename files all the time. We refactor.

Git doesn’t handle renames as a “first class operation” – renames are just a delete operation followed by an add operation. This is the same as Subversion. I assume Git handles it much better than Subversion, but I wanted a SCM that has it built in.

So, I decided to start using Bazaar: renames are a first class operation in Bazaar, and it also has “Intelligent Merging” to cope with your Dev Studio file moves or renames.

For a full feature list of a number of SCM systems see this source control comparison page.

So far, I’m happy:

  • It runs natively in windows (I didn’t really want to run a unix-type shell to get Git working).
  • It is easy to work with from the command line (I thought I’d miss Dev Studio integration, e.g. VisualSVN and Ankh, but I don’t).
  • I even decided not to install TortoiseBZR – you don’t need it. [Tortoise is one of the reasons I wanted to move away from Subversion so I didn’t want to install the BZR equivalent.]
  • BZR comes with some GUI applets if you really need your GUIs. For example, there is a useful one for viewing change logs (command: “bzr qlog”)

To make the move, check out getting started with Bazaar source control.

Posted in Bazaar Source Control | Tagged: , , , , | 4 Comments »