13.3 Create a project in RStudio and commit a file

Next, return to RStudio and configure Git via the Terminal (Figure 13.3A)). Remember Git is a piece of software running on your own computer. This is distinct to GitHub, which is the repository website.

We will now create a new project which we want to back-up to GitHub.

In RStudio, click New project as normal (Figure 13.3B). Click New Directory. Name the project and check Create a git repository. Now in RStudio, create a new script which you will add to your repository.

After saving your new script (e.g. test.R), it should appear in the Git tab beside Environment.

Tick the file you wish to add, and the status should turn to a green ‘A’ (Figure 13.3C). Now click Commit and enter an identifying message in Commit message (Figure 13.3D).

It is important to commit prior to linking the project and the GitHub repository.

You have now committed the current version of this file to your repository on your computer/server. In the future you may wish to create branches to organise your work and help when collaborating.

Configure Git global settings via RStudio and create a new project.

FIGURE 13.3: Configure Git global settings via RStudio and create a new project.