Version Control - git hell

Ondřej Mottl

Git

  • local software
  • keep track of changes of files


GitHub

  • host server
  • store the (git) data
  • project management, collaboration, publishing

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

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.

Installation

Is Git already installed?

Check your version:

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

Installation

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

Choose your weapon

GUI = Graphical User Interface

You will still need to know the basics of shell.

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!

RStudio

RStudio IDE

Instal/update R

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

R.version.string
#> [1] "R version 4.4.1 (2024-06-14, Race for Your Life) "

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")

Can you hear me now?

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

Step 1 - Git

Confirm that git has your name and email by running:

usethis::use_git()

If needed, set the name and email by running:

# 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 Git.

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()

Can you hear me now?

Other useful functions:

# Read about PAT
usethis::gh_token_help()

# List all git settings
usethis::git_sitrep()

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

If everything fails, you can try to set up the PAT manually into your .Reviron file.

Simply run:

usethis::edit_r_environ()

Add a line like this, but substitute your PAT:

GITHUB_PAT=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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.

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