Version Control Basic

Set Up Git


Let’s say that you’re working on analyzing fish scale size data one day. Unfortunately you weren’t using version control and your cat jumped all over your keyboard and managed to replace your analysis code with:

asd;fljkzbvc;iobv;iojre,nmnmbveaq389320pr9c9cd

ds8
a
d8of8pp

before somehow hitting Ctrl-s and overwriting all of your hard word.

Determined to not let this happen again you’ve committed to using git for version control.

Install Git for your operating system.

Git

Windows

  1. Download the Git for Windows installer.
  2. Run the installer and follow the steps bellow:
    1. Click on “Next”.
    2. Click on “Next”.
    3. Click on “Next”.
    4. Click on “Next”.
    5. Click on “Next”.
    6. Select “Use Git from the Windows Command Prompt” and click on “Next”. If you forgot to do this programs that you need for the workshop will not work properly. If this happens rerun the installer and select the appropriate option.
    7. Click on “Next”. Keep “Checkout Windows-style, commit Unix-style line endings” selected.
    8. Select “Use Windows’ default console window” and click on “Next”.
    9. Click on “Next”.
    10. Click on “Finish”.

Mac OS X

  1. Open up the Terminal, type in “git” and press enter.
  2. This should cause a pop-up window to appear. It will have several options; click on “Install” (not “Get Xcode”, see “Installing Xcode” for that).
  3. Click “Agree”.
  4. When the install is finished, click “Done”.
  5. To make sure this worked, type in “git” in the Terminal and press enter. Some information will come up, including a list of common commands.

If this doesn’t work you can try the following:

For OS X 10.9 and higher, install Git for Mac by downloading and running the most recent “mavericks” installer from this list. After installing Git, there will not be anything in your /Applications folder, as Git is a command line program. For older versions of OS X (10.5-10.8) use the most recent available installer labelled “snow-leopard” available here


Then create a new repo at the Github organization for the class:

  1. Navigate to Github in a web browser and login.
  2. Click the + at the upper right corner of the page and choose New repository.
  3. Choose the class organization (e.g., fish497-2018) as the Owner of the repo.
  4. Fill in a Repository name that follows the form FirstnameLastname.
  5. Select Initialize this repository with a README.
  6. Click Create Repository.

Next, set up a project for this assignment in RStudio with the following steps:

  1. File -> New Project -> Version Control -> Git
  2. Navigate to your new Git repo -> Click the Clone or download button -> Click the Copy to clipboard button.
  3. Paste this in Repository URL:.
  4. Leave Project directory name: blank; automatically given repo name.
  5. Choose where to Create project as subdirectory of:.
  6. Click Create Project.
  7. Check to make sure you have a Git tab in the upper right window.