Sunday 29 May 2011

Visual Studio 2010 Source Control using Windows + Git + Git Extensions + DropBox


The following lays out a way to use Git + Git Extensions + Drop Box with an existing Visual Studio 2010 project. This will allow you to collaborate across multiple PC’s on the same project.

There may be quite a few steps, but it’s all quite simple stuff…

  1. Install Git
  2. Install Git Extensions
  3. Install Drop Box
  4. On the machine with the working Solution / project;
    1. Browse to your DropBox folder using Windows Explorer
    2. Create a directory to hold your Cloud Based Repo’s, for example /repos
    3. Create a directory in your new repos directory to hold your Remote Cloud Based Project Repo, e.g. /repos/myproject/
    4. Open a Git Gui
    5. Click “Create a new repository”, and point it to the directory housing the local copy of your Solution / Project.
    6. Click “Ok”, and let Git Gui create a repository within your Solution location
    7. Create a .gitignore file in your favourite editor, and add the following sub directories (don’t forget that the directories are case sensitive, and will require a trailing forward slash)
      1. The “/bin” directory for all projects
      2. The “/obj” directory for all projects
      3. Any other directories which you don’t require in your repository
    8. Open your new repository in Git Gui
    9. It should show all files ready to be staged and committed in the top left window.
    10. Make sure this list contains all the files you’re expecting
    11. Select all files and select “Stage to Commit” from the “Commit” menu
    12. Add a commit comment such as “Origin”
    13. Press Commit
    14. Choose “Add” from the “Remote” menu
    15. Choose a name for your remote repository. e.g. DropBox
    16. In windows explorer copy the path to the remote repository contained in your DropBox folder at Step 2 above
    17. In the “Further Action” section, choose “Initialize Remote Repository and Push”. This should then setup your Cloud Based Repository
  5. On the Users’ machine who wishes to collaborate;
    1. Create a directory to house the Solution / Project
    2. Open Git Gui
    3. Again create a repository at the location in Step 1
    4. Again, add a Remote Repository in exactly the same way as in steps 13, 14, 15 and 16 above (NOT step 17!).
    5. However, in the “Further Action” section, choose “Fetch Immediatly”
    6. For some reason this doesn’t seem to actually go ahead and fetch all the project files, so flip back to windows explorer
    7. Browse to the directory of your Solution / Project as created in Step 1
    8. Right Click on the Directory and go to to Git Extensions –> Pull
    9. In the “Pull From” section, and the “Remote” Drop Down, select the name of your Remote Cloud Based Repo. e.g. DropBox
    10. In the “Branch” section, and the “Remote Branch”, select “master”
    11. In the “Merge Options” section, make sure “Merge remote branch to current branch” is selected and that the “Auto stash” checkbox is clear
    12. Hit “Pull”
    13. You should now be able to see all your project files filled into your working directory

You can now;

  • Make changes to the project,
  • Stage and commit the changes
  • Push the Changes to the Remote Cloud Based Repository
  • Pull those changes on other machines
  • Track changes between machines
  • And much more