Version Control

Version control is software that helps you keep track of changes to your code files. At the simplest level this is like backing up files so you have previous versions that you can recover if needed. However, since large code development involves large numbers of people working on hundreds of files software for version control has grown in complexity to address those needs. There are a number of popular version control programs we will use git for this class. There are also websites that host code and can be synced with a version control system, we will make use of GitHub to store our repositories. For this class you will have to create an account at GitHub.

Version control systems work a little different then just backing up files by having a repository. The repository is where the files are stored. The normal workflow would be to check out files from the repository, make you changes and then recommit them back to the repository. We will store our repositories on GitHub, you can create a repository on GitHub using the web interface, then you’ll want to clone it to your machine. The 3 commands for cloning from the repository, pulling any changes from the repository and pushing your changes back to the repository are:

git clone – clones the repository to the current directory
git pull – pulls the latest versions of all files from the repository
git push – pushes your commited changes back to the repository

New users to git are often confused by the commit process. When you make change to a file on your machine those changes will not be known by git. You have to add every file you want to be in the repository and you have to commit any changes for them to be there:

git add – adds a file to staging
git commit -m – commits the files in staging to the repository

In order to checkout a repository, add a file to it and push it back to repository one would need to execute:

git clone
git add
git commit -m added file
git push