BYU

Office of Research Computing

Revision Control

Revision Control has many uses. One of its simplest uses is providing a change history for code. There are many different flavors of Revision control each with its pros and cons.

Git

Git is one of many popular options for revision control. It is very easy to use and set up.

Setup

In the directory containing your source code


git init
git add .
git commit -am "Some sort of useful message"

This will initialize the git repository, add all files and directories to the repository, and commit them with a message describing the commit.

From here, any time you want to checkpoint your code, just run


git commit -am "Message describing commit"

git also supports branching, which is very useful if you have multiple versions you want to switch between.


git branch VersionB
git checkout VersionB

This will create a branch called VersionB. All commits will be made to the VersionB branch.

To see all available branches:

git branch

To switch to another branch, commit any changes that need committing then run:

git checkout master

Where master is a different branch (the main branch of the repository is called master. You can checkout any branch by specifying its name in place of master)

To merge changes from another branch into the one currently checked out:


git merge VersionB

Assuming we are currently in the master branch, git will merge all changes made in VersionB to master.

Git Manual