Kash Farooq's software development blog

.NET Developer

Archive for the ‘Git Source Control’ Category

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):

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

You’ll see a message like:

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

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):

c:
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.

Advertisements

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:

obj
bin
_ReSharper.*
*.csproj.user
*.resharper.user
*.resharper
*.suo
*.cache
~$*

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