Mentions légales du service

Skip to content
Snippets Groups Projects
rstudio-git.org 3.43 KiB

Using Git from RStudio

Table of Contents

To begin

If you have never used git with RStudio, we strongly advise that you follow our tutorial on using git from RStudio (/”RStudio et Gitlab”/ ). Before proceeding, make sure you also have followed the “git/GitLab configuration” tutorial.

Alternatively, you may want to watch this video (in English). If you do not like videos, you should have a look at the step-by-step explanations from Software Carpentry. It comes with many screenshots and is quite progressive.

Cloning a repository

Open RStudio and do the following steps:

  • Create a new version controled project: File / New Project / Version Control

    rstudio_images/new_project.png

    rstudio_images/git.png

  • Get the URL from your GitLab repository:

    rstudio_images/adresse_depot_v2.png

  • Indicate this URL in the “Repository URL” field (you may want to prefix this URL with =xxx@= where =xxx= is your Gitlab id to avoid repeatedly giving it later on).

    rstudio_images/clone.png

  • If you’re behind a proxy, git should be configured accordingly. Check the “Dealing with proxies” section.
  • Git will then connect to Gitlab and fetch a whole copy of the repository.
  • RStudio should restart in a mode related to Git:

    rstudio_images/rstudio.png

  • The file manager on the right, allows you to browse the version controled repository.

Modifying a file

  • Open Module2/exo1/toy_document.Rmd and perform a simple modification.
  • Save
  • Go to the Git menu to commit

    rstudio_images/commit.png

    rstudio_images/commit2.png

  • Select the lines to commit and then click on commit

    rstudio_images/commit5.png

    Your modifications have now been commited on your local machine. They haven’t been propagated to GitLab yet.

  • Click on push to propagate them on GitLab

    rstudio_images/push.png

    rstudio_images/push2.png

    rstudio_images/push3.png

    NB: You won’t be able to propagate your modifications on GitLab if some modifications have been done on GitLab in the meantime. rstudio_images/push4.png

  • You should first merge these remote modifications locally. Click on pull to get these modifications on your machine.

    The video Let’s demystify Git, Github, Gitlab/Working together explains how to handle conflict with Git.