Git: Setup & Configuration

FAIR & Reproducible Teaching with Quarto & Git
Course at University of Hamburg
Slides | Source
License: CC BY 4.0

10:45

Schedule

Day 1

Day Date Time Title
1 2026-03-20 09:30 - 10:00 Welcome & Introduction
1 2026-03-20 10:00 - 10:30 Quarto: Introduction
1 2026-03-20 10:30 - 10:45 Quarto: Presentations
1 2026-03-20 10:45 - 11:00 Git: Setup & Configuration
1 2026-03-20 11:00 - 11:15 Command Line
1 2026-03-20 11:15 - 12:00 Git: Basics
1 2026-03-20 12:00 - 13:00 Lunch Break
1 2026-03-20 13:00 - 14:00 Git: Remotes
1 2026-03-20 14:00 - 15:00 Git: Collaboration
1 2026-03-20 15:00 - 15:30 Quarto: Publication to GitHub Pages
1 2026-03-20 15:30 - 16:00 Git: Tags & Releases

1 This session: Git: Setup & Configuration

Objectives

πŸ’‘ You know how to set up Git for the first time
πŸ’‘ You have set up Git on your computer
πŸ’‘ You know how to configure your username and email address in Git
πŸ’‘ You understand the difference between the three Git configuration levels
πŸ’‘ You know how to set up a new RStudio Project for Quarto

Tasks

In this session, you will work on the following tasks:

  1. Reading: Read the chapter(s) Setup in the Version Control Book.
  2. Implementation: Try out the commands in the chapter.
  3. Exercises: Work on the exercises.

As always:

  1. Try out the commands of this session and play around with them.
  2. Check whether you have achieved the learning objectives.
  3. Ask questions!

Exercises

  1. If needed, navigate into the project folder when using the command line.
  2. Set your Git username.
  3. Set your Git email address.
  4. Change the default name of the initial branch to main
  5. πŸš€ Optional: Change your default text editor when using the command line.
  6. List the Git configuration settings.

Solutions

1cd my-project
2git config --global user.name "Your Name"
3git config --global user.email "your.email@example.com"
4git config --global init.defaultBranch main
5git config --global core.editor "vim"
6git config --list
1
Optional: Use cd (in combination with absolute or relative paths) to navigate into the project subfolder.
2
Set your global Git username using git config --global user.name "Your Name". Replace Your Name with your name and don’t remove the quotation marks.
3
Set your global Git email address using git config --global user.email "your.email@example.com". Replace your.email@example.com with your email address and don’t remove the quotation marks.
4
Change the default name of the initial branch to main using git config --global init.defaultBranch main.
5
Optional: Change your default text editor. In this example, the default text editor is changed to Vim using git config --global core.editor "vim".
6
List the Git configuration.

2 Appendix

Important note: Git repository in /user folder?

  • Please make sure that your my-project folder is in a suitable place (for example, in the Desktop, Documents folders or where you keep your course-related files, …) and not in your user directory!
  • You can check your current working directory by running pwd in your my-project folder.
  • Also: Always remember to cd into your repository before you execute Git commands!
  • If your my-project folder is in your user directory, please tell Lennart and we can fix it.

Tip: To prevent ever creating a Git repository inside your /user folder, you can use:

touch ~/.git

Running git init in the user directory now results in a (desired) error:

fatal: invalid gitfile format: /Users/user/.git