Git: Basics
Objectives
π‘ 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.
Tasks
In this session, you will work on the following tasks:
- Reading: Read the chapter(s) First steps with Git (Optional: Git Essentials) in the Version Control Book.
- Implementation: Try out the commands in the chapter.
- Exercises: Work on the exercises.
As always:
- Try out the commands of this session and play around with them.
- Check whether you have achieved the learning objectives.
- Ask questions!
Exercises
First steps with Git
- Create a
my-projectfolder and turn it into a Git repository. - Make changes to the files and folders in your project.
- Stage and commit your changes to the repository.
Basic Git workflow
- Commit at least three additional changes in your files.
- Create a
.gitignorefile- Everyone: Create a random file that you want to ignore, for example
random-file.docx. - Add the random file to the
.gitignorefile, stage and commit your changes. - All macOS users: Let your repository ignore
.DS_Store.
- Everyone: Create a random file that you want to ignore, for example
- π Make at least one commit using
git commit --amend.- For example, add file 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 file without a title first, commit, then add a title and use
- π Optional: Commit
.gitkeepin an otherwise empty directory
Slides
NoteHow can I download the slides as a PDF file?
To export 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.
Resources
- Version Control Book: First steps with Git
- Version Control Book: Git Essentials
- Pro Git: Chapter 2 β Git Basics by Scott Chacon and Ben Straub