• Home
  • About
  • Schedule
  • Sessions
  • Code of Conduct

Contents

  • This session
  • Learning objectives
    • Setup
    • First steps with Git
  • recipes project
  • Exercises
    • Setup
    • First steps with Git
    • Basic Git workflow
  • Slides
  • Cheatsheet
    • Setup
    • First steps with Git

Setup & First steps with Git

Session 03

Starts at:

11:00

Slides Chapter: Setup Chapter: First steps with Git Survey: Git Basics

This session

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

  1. Reading: Read the chapters “Setup” and “First steps with Git” in the Version Control Book.
  2. Implementation: Try out the commands in the chapter.
  3. Exercises: Work on the exercises for the recipes project.
  4. Quiz: Test your knowledge with the quiz.

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!
  4. Let’s git started!

Learning objectives

Setup

💡 You know how to set up Git for the first time
💡 You have set up Git on your computer
💡 You understand the difference between the three Git configuration levels
💡 You know how to configure your username and email address in Git
💡 You have set up your preferred text editor when working with Git
💡 You can escape the command-line text editor Vim

First steps with Git

💡 You can initialize a Git repository
💡 You can stage and commit changes
💡 You know how to explore the commit history
💡 You can compare different commits
💡 You know how to use and create a .gitignore file
💡 You can discuss which files can (not) be tracked well with Git and why
💡 You know how to track empty folders in Git repositories

recipes project

At the end of this session, you should have accomplished the following:

  1. You set up Git.
  2. You initialized your recipes folder as a Git repository.
  3. You committed your first recipe to the recipes repository.

Please keep the recipes folder! We will continue to use it in the following sessions.

Exercises

Setup

  1. Set your Git username and email address.
  2. Change the default name of the initial “branch” to main.
  3. 🚀 Optional: Change your default text editor.

First steps with Git

  1. Create a recipes folder and turn it into a Git repository.
  2. Add a short recipe to recipes.txt (any favorite or an intriguing AI-generated one).
  3. Stage and commit your changes to the repository.

Basic Git workflow

  1. Commit at least three additional changes in recipes.txt.
  2. Create a .gitignore file
    • Everyone: Create a random file that you want to ignore, for example random-file.docx.
    • Add the random file to the .gitignore file, stage and commit your changes.
    • All macOS users: Let your repository ignore .DS_Store.
  3. 🚀 Make at least one commit using git commit --amend.
    • For example, add a recipe without a title first, commit, then add a title and use git commit --amend to add the title change to the same commit.
  4. 🚀 Optional: Commit .gitkeep in an otherwise empty directory

Note: There are several terms in these instructions that might still be unfamiliar to you, for example “repository”, “stage” or “commit”. Don’t worry, you will learn about what these terms mean in the chapters.

Slides

How can I download the slides as a PDF file?

To print the slides to PDF, do the following:

  1. Toggle into Print View using the E key (or using the Navigation Menu).
  2. Open the in-browser print dialog (CTRL/CMD+P).
  3. Change the Destination setting to Save as PDF.
  4. Change the Layout to Landscape.
  5. Change the Margins to None.
  6. Enable the Background graphics option.
  7. Click Save.

Note: This feature has been confirmed to work in Google Chrome, Chromium as well as in Firefox.

Here’s what the Chrome print dialog would look like with these settings enabled:

Screenshot of Chrome print dialog with the first slide/page of 43 shown on the left, and print options on the right. The Destination print option has Save as PDF selected.

These instructions were copied from the Quarto documentation (MIT License) and slightly modified.

Cheatsheet

Setup

Command Description
git config Get an overview of Git config commands
git config --global "user.name" Sets Git username
git config --global "user.email" Sets Git email address
git config --global core.editor "editorname" Sets Git text editor
git config --global init.defaultBranch main Sets default branch name to main
git config --list Views set Git configurations

First steps with Git

Command Description
git init Initializes a folder as Git repository
git status Views Git tracking status of files in the repository
git add Adds file(s) to the staging area
git commit Commits staged files
git commit -m "commit message" Commits staged files with a commit message
git log Views past commits
git diff Views made changes compared to the last commit
© 2024 Dr. Lennart Wittkuhn
 
License: CC BY-SA 4.0