Overview

Step 0: Git and R/RStudio installation and GitHub account registration

We assume the following

Step 1: Tell RStudio where to find Git

Step 2: Create a new repository on GitHub

Do this once per new project. Here we just create a disposable test repository, so don’t worry too much about the name.

Log on to GitHub, go to your personal page (click your name on the top right), choose “Repositories” and click the green “New” button. On this page

This brings you to your new repository. See the file README.md with the name and description of your repository.

If this does not work, please make sure you have registered a GitHub account and you are logged in.

Before you leave this page, copy the URL of your repo to the clipboard. In the right sidebar, below settings, you should see something like this, where you can click on the clipboard icon.

Step 3: Clone the new GitHub repository to your computer via RStudio

Do this once per new project.

This should download the README.md file that we created on GitHub in the previous step. Look in RStudio’s file browser pane for the README.md file.

Awesome, you can now automatically download content from your (or any other public) GitHub repository!

Step 3, plan B

If Step 3 does not work, here is something to try:

Now try this in the shell:

Sometimes this initial usage from the command line is necessary, in order to elicit and remember your GitHub username and password. Best case scenario: you will now be able to pull and push from RStudio.

Step 4: Make local changes, save then, and commit them

Do this every time you finish a valuable chunk of work, probably many times a day.

Step 5: Push your local changes online to GitHub

Do this a few times a day, but possibly less often than you commit.

You have new work into your local Git repository, but the changes are not online yet.

Note from the future: although you are not collaborating with anyone yet, that day is coming. Here is where you should get into the habit of pulling changes from GitHub before you attempt to push. This will save you some grief. Hit the blue “Pull” button.

To push changes online, hit the green Push button. The three most likely outcomes:

  1. Your push is accepted and the online GitHub repository is updated. This means that RStudio is successfully using your GitHub username and password. You are done.

  2. RStudio asks for your GitHub username and password, then your push is accepted and the online GitHub repository is updated. Learn how to make git remember your username and password to avoid having to type those every time.

  3. RStudio does not ask for your username and password, but it is not sending them. The push fails and the online Github repository is not updated. This is a bug in RStudio and not your fault. Follow the work-around in step 5, plan B, and/or learn how to make git remember your username and password.

Step 5, plan B

If the push in step 5 does not work, here is something to try:

This will certainly ask for your username and password, and update the GitHub repository online. Then, learn how to make git remember your username and password to save you from authenticating every time and so that you can push from RStudio directly.