Version Control - git hell

Ondřej Mottl

< — use arrow keys to navigate —>

Half the battle

Getting all the necessary software installed, configured, and playing nicely together is honestly half the battle … Brace yourself for some pain

Resources

Software for version control

Git

GitHub

  • local software
  • keep track of changes of files
  • you need to install it!
  • host server (store the data)
  • project management, collaboration, publishing
  • you need an account!

GitHub

Making the account

You will need a GitHub account.

It is super easy to create one, just go to GitHub.com and follow the instructions.


Some tips

  • Use a professional username, preferably your name
  • Use university/science institute email address

Git

🐚 shell intermezzo

You will need to use the shell (command line) to interact with Git.

The actuall tool might differ based on your operating system.

Please refer to this document for more information.

As most users will be on Windows, we will focus on Command Prompt here. You can can open it by typing cmd in the Windows search bar.

Installation

Is Git already installed?

Open Command Prompt and check your version:

git --version
## git version 2.42.0.windows.2

Installation

You can click on the tabs below to see installation instructions for your operating system.

Download and install Git for Windows

Download and install Git for MacOS

Ubuntu or Debian Linux:

sudo apt-get install git

Fedora or RedHat Linux:

sudo yum install git

Configuration

Introduce yourself to Git 👋


❗Note to substitute your name and the email address❗


Use the same email address as the one you used for GitHub account.

git config --global user.name "Jane Doe"
git config --global user.email "jane@example.com"
git config --global --list

Git GUI client

Graphical User Interface

There are many options, some of the most popular are:

The next sections of the presentation will expain setup of each of these GUI clients. You only need to choose one!

If you do not use either of them, I recomend using GitHub Desktop

GitHub Desktop

GitHub Desktop

Installation

Dowload and install GitHub Desktop.

There is an option to install for all Operating Systems (Windows, Linux, MacOS).

Configuration

Link your GitHub account to GitHub Desktop.

RStudio

RStudio IDE

Instal/update R

Make sure you have the latest version of R installed. You can check the version by running the following code in R Console:

R.version.string
#> [1] [1] "R version 4.5.1 (2025-06-13 ucrt)"

Install the newest version of R from CRAN.

Bonus

Check out {updateR} package to update R and all installed packages.

Install/update RStudio

Make sure you have the latest version of RStudio installed. You can check the version by running:

rstudioapi::versionInfo()$version

You can download the newest version of RStudio from RStudio website.

{usethis} package

The {usethis} package is a collection of functions that help automate package and project setup tasks.

Install the package by running:

install.packages("usethis")

RStudio Projects

R-studio is using Projects, which are a way to organize your work in RStudio.

You can create a new project by going to File -> New Project... and following the instructions.

Can you hear me now?

We now need to make sure that RStudio can communicate with Git.

Step 1 - Git

You need to activate Git for your RStudio Project by running:

usethis::use_git()

If needed, set the name and email by running (replace with your name and email):

# replace with your name and email
usethis::use_git_config(user.name = "Jane Doe", user.email = "jane@example.com")

Can you hear me now?

We now need to make sure that RStudio can communicate with GitHub.

Step 2 - PAT (Personal Access Token)

You can check more details about it here and here.

usethis::create_github_token()

Click Generate token and copy the token to a safe place.

Can you hear me now?

Add the PAT to RStudio by running:

Step 3 - RStudio3

gitcreds::gitcreds_set()

You will be prompted to enter the PAT you generated in the previous step (“Replace these credentials” option).

Can you hear me now?

Other useful functions to check if everything is set up correctly:

# Read about PAT
usethis::gh_token_help()

# List all git settings
usethis::git_sitrep()

# Check if PAT is set
gh::gh_whoami()

Visual Studio Code

Visual Studio Code

Installation

Download and install Visual Studio Code.

There is an option to install for all Operating Systems (Windows, Linux, MacOS).

GitHub integration

Install the GitHub Pull Requests and Issues extension.

Link your GitHub account to Visual Studio Code.

Outro

About me

Ondřej Mottl Assistant Professor at Charles University

This presentation