| Command | Description | 
|---|---|
| git init | Initializes a folder as a Git repository | 
| git status | Shows 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 | 
This session
In this session, you will work on the following tasks:
- Reading: Read the chapter(s) “Git Essentials” in the Version Control Book.
- Implementation: Try out the commands in the chapter.
-  Exercises: Work on the exercises for the city-guideproject.
- Quiz: Test your knowledge with the quiz.
As always:
- Try out the commands of this session and play around with them.
- Check whether you have achieved the learning objectives.
- Ask questions!
- Let’s git started!
Learning objectives
First steps with Git
💡 You can initialize a Git repository.
 💡 You can check the status of a Git repository.
 💡 You understand the difference between the staging area and a commit.
 💡 You can stage and commit changes.
 💡 You understand the difference between a commit message and a description.
Git Essentials
💡 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.
city-guide project
At the end of this session, you should have accomplished the following:
- Commit at least three changes in city-guide.txt.
- Make at least one commit using git commit --amend.- For example, add a a new entry without a title first, commit, then add a title and use git commit --amendto add the title change to the same commit.
 
- For example, add a a new entry without a title first, commit, then add a title and use 
- Create a .gitignorefile.- Everyone: Create a random file that you want to ignore, for example image.jpg.
- All macOS users: Let your repository ignore .DS_Store.
 
- Everyone: Create a random file that you want to ignore, for example 
- 🚀 Optional: Commit .gitkeepin an otherwise empty directory.
Please keep the city-guide folder! We will continue to use it in the following sessions.
Exercises
Amend a commit
- If needed, navigate to the project folder using the command line.
- Make additional changes to your project text file.
- Stage the changes.
- Amend the previous commit to include the new changes.
- Check the commit history to verify that the last commit message has not changed.
For example, add a new entry without a title first, commit, then add a title and amend the previous commit to add the title change to the same commit.
Create a .gitignore file
- If needed, navigate to the project folder using the command line.
- Add a random file to your repository that you want to ignore, for example an image file like image.jpg.
- Check the state of your repository to confirm that Git noticed the added file.
- Create a .gitignorefile.
- Add the random file to the .gitignorefile.
- Check the state of your repository again to confirm that Git now ignores the added file.
- Stage the changes in your repository.
- Commit the .gitignorefile using a descriptive commit message.
- 🚀 All macOS users: Let your repository ignore .DS_Store.
Slides
To print the slides to PDF, do the following:
- Toggle into Print View using the E key (or using the Navigation Menu).
- Open the in-browser print dialog (CTRL/CMD+P).
- Change the Destination setting to Save as PDF.
- Change the Layout to Landscape.
- Change the Margins to None.
- Enable the Background graphics option.
- 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:

These instructions were copied from the Quarto documentation (MIT License) and slightly modified.
Cheatsheet
First steps with Git
Git Essentials
| Command | Description | 
|---|---|
| git log | Views past commits | 
| git diff | Views made changes compared to the last commit | 
| git mv | Renames or moves files and automatically stages the changes |