4 Version Control with Git

4.2 Install Git

4.2.1 For 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. Keep “Use Git from the Windows Command Prompt” selected and click on “Next”. If you forgot to do this, rerun the installer and select the appropriate option.
    4. Click on “Next”.
    5. Keep “Checkout Windows-style, commit Unix-style line endings” selected and click on “Next”.
    6. Keep “Use Windows’ default console window” selected and click on “Next”.
    7. Click on “Install”.
    8. Click on “Finish”.
  3. If your “HOME” environment variable is not set (or you don’t know what this is):
    1. Open command prompt (Open Start Menu then type cmd and press [Enter])
    2. Type the following line into the command prompt window exactly as shown: setx HOME "%USERPROFILE%"
    3. Press [Enter], you should see SUCCESS: Specified value was saved.
    4. Quit command prompt by typing exit then pressing [Enter]

4.2.2 For Mac

Install git-osx-installer.

4.2.3 For Linux

install `git’ from your distro’s package manager.

4.3 Lesson

Adapted from Version Control with Git by Software Carpentry.

git config --global user.name "Liming Wang"
git config --global user.email "lmwang@gmail.com"
git config --global color.ui "auto"

4.4 Exercise

  1. Set up your git installation for use with GitHub;
  2. Turn the RStudio project you have been working on into a git repository;
  3. Commit it to github by following these steps: http://happygitwithr.com/existing-github-last.html.

4.5 Learning more

  1. Try Git
  2. Pro Git, a book by Scott Chacon and Ben Straub