Materials originally developed for the "Version control for research" breakout session of the Best Practice for Code Archiving workshop, 11 December 2016.
Step through the instructions below to make sure that you have everything you need to get started.
You can download git here: https://git-scm.com/downloads
If prompted, select the option to add the installation location to system path.
To check that the installation worked, open a terminal or command prompt:
Windows
Mac
Type git version
. You should see a short message containing some
version information.
After installing git, you need to tell it who you are. Open a terminal window or command prompt (see above) and type the following:
git config --global user.email "you@youremail.com"
git config --global user.name "Your Name"
You can also configure git to use your preferred editor for commit messages, e.g. on Mac:
git config --global core.editor nano
or on Windows:
git config --global core.editor notepad
It’s a good idea to follow this step since the default editor selected by git is quite difficult to use!
GitHub is a popular online hosting service for git repositories. It provides a useful interface for collaboration and code sharing.
Create a free account on GitHub:
If you have an academic email account you should use it here.
GitHub users can create an unlimited number of public and public repositories but some features for private repositories are restricted. Academic users can sign up here for access to GitHub Pro features here:
This requires your account to be associated with an academic email address.
It may take a while to receive the verification email for this step. Don’t worry, we won’t need this for the tutorial.
If you’re going to be following the section on using git through RStudio, you’ll need to make sure you have an up-to-date version of RStudio installed. Downloads are available at:
https://www.rstudio.com/products/rstudio/download/
Open Rstudio and go to the options pane (Windows users, look in
Tools -> Options, Mac users, look in RStudio ->
Preferences). The last entry in the ribbon on the left is
Git/SVN. Select that, and look at the contents of the box saying
Git executable. It should say something like C:/Program Files
(x86)/Git/bin/git.exe
(Windows) or /usr/bin/git
(Mac). If instead
it says (Not found)
, RStudio cannot find git.
If RStudio cannot find git (and testing git version
on the command
line worked above), then click the Browse… button and navigate
to the path corresponding to your installation of git.