Welcome to the second part of this series. Today we will talk about setting up source control.
Why do we need source/version control?
I think I won’t add anything new to the conversation if I say the following are some of the nice features any version control offers:
- consistency of file and directory names among all team members
- easy to revert changes
- better team communication
- potentially easy deployment of code
- tracking what was changed and who made the change
Why did I choose Git?
Apart from the fact that there are tons of reasons specified elsewhere why Git is great, I just like the simplicity of it. And its fast!
Why Git and Dropbox?
Dropbox provides a great way for me to keep my repository on the cloud, thus constantly maintaining a backup. Dropbox works great with Git, though I would think any source control software that has a file base structure would be fine with this setup.
Lets get started.
Please keep in mind that this is not a tutorial for Git or Dropbox.
- If you haven’t setup Git already, do so. On windows download the latest release of Git Extensions from https://code.google.com/p/gitextensions/downloads/list
- Install the package and keep “Open SSH” on the option page (you will see)
- Once Git is setup, start git-bash
- Change directory (cd) to the folder where you plan to do keep your working copy of the code (c:projectmyProject in this example)
- Once in the folder, setup a new git repository using the following command – git init
- this will work even if the code already exists (existing visual studio solution)
- Add a gitignore file suitable for your Visual Studio project – touch .gitignore
- The information from this link can be copied into this file – https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
- Now we will add the initial changes to our to-be-commited list – git add .
- Now commit the changes to the local repository – git commit -m “Initial commit”
- Change directory to Dropbox folder – cd c:Dropbox
- Create a new directory to store your cloud repository – mkdir myProject
- Change directory to newly created folder – cd myProject
- Create a bare Git repository – git init –bare myProject.git
- Change directory back to your original working copy repository – cd c:projectmyProject
- Add link to remote repository – git remote add dropbox c:DropboxmyProjectmyProject.git
- Push current changes to remote repository – git push dropbox master
You are all set now! Now you can clone this bare repository from any machine with the same access to the Dropbox folder myProject.