Git and Visual Studio (2010)

Here are a couple notes on how I use Git with Visual Studio and a shared folder as a remote repository.

Simple Setup

Let's walk trough the basic setup steps.

  1. Create a new visual studio project

  2. Add a nice .gitignore file to the project folder. Good example: git ignore file

  3. Open git command line console and initialize your project in the project folder .. code-block:: bash

    git init git add git commit -m "add initial project files"

  4. Outside the project directory, create a bare repository

    git clone --bare ProjectName ProjectName.git  # note common naming convention for bare repo
    
  5. Copy bare repository to a remote location (in my case a file share where other developers have access)

  6. Change into project folder and update remote remote repo location

    git remote add origin /x/Shared/git/ProjectName.git
    
  7. Now add development branch (take a look here for a good branching model).

    git checkout -b develop master
    
  8. Push changes (including branches) to the remote repo

    git push -all
    

Simple Development with Branching Model

Now, when ready to begin some development:

  1. First, create a new branch off develop branch and begin coding

    git checkout -b feature-NewSprocket develop
    ...
    git commit -m "Added new sprocket code"
    
  2. And when finished merge back, delete, and push (don't forget to commit final changes)

    git checkout develop
    git merge --no-ff feature-NewSprocket
    git branch -d feature-NewSprocket  # deletes branch
    git push origin develop  # push develop branch to origin
    

Simple Steps for Release Cylce

Later, here are basic release steps:

  1. Create your release branch off develop

    git checkout -b release-1.0 develop
    
  2. When ready to finalize, check everything in and bump release info, then merge to master

    git checkout master
    git merge --no-ff release-1.0
    git tag -a 1.0
    git push  # do we need to specify --tags or --all here to ensure the tag gets pushed to the origin?
    
  3. Don't forget to merge any changes in release back into develop as well before deleting

    git checkout develop
    git merge --no-ff release-1.0
    git branch -d release-1.0
    

Quirks

It's a good idea to save your solution and/or project file before you commit as some of the changes to the .slc and .proj files don't get written immediately. This can cause odd behavior and necessitate amending your last commit to include apparent missing files or project changes.