Tsallaka zuwa abun ciki
Justice Tech School

Git Exercises

Fill in the blanks to check your knowledge. Each exercise belongs to a lesson.

Git Introduction

Exercise

Which command starts a repository?

git 

Setup and git init

Exercise

Set your name.

git  --global user.name "Ada"

Git Config

Exercise

Read a setting.

git config .name

Version and Help

Exercise

Open the manual of commit.

git  commit

Inside the .git Folder

Exercise

Where does Git keep history?

The  folder

Staging and Committing

Exercise

Stage every change.

git  .

Status and Log

Exercise

Show only the last 2 commits.

git log  2

Diff

Exercise

Show staged changes.

git diff 

.gitignore

Exercise

Name of the ignore file.

Undoing Changes

Exercise

Discard edits in a file.

git  a.txt

Writing Commit Messages

Exercise

Add a message inline.

git commit  "Add login"

Staging Selected Files

Exercise

Stage one file.

git add 

Removing and Renaming Files

Exercise

Rename a tracked file.

git  a.txt b.txt

Listing and Showing Files

Exercise

Print a file from the last commit.

git show HEADa.txt

Commit Tracked Changes in One Step

Exercise

Include tracked changes.

git commit -m "msg"

What Is Version Control

Exercise

Create a repository.

git 

Working Tree, Index and Repository

Exercise

Move to the staging area.

git  a.txt

Your First Commit

Exercise

Commit with a message.

git commit  "msg"

Reading git status

Exercise

Short status.

git status 

Viewing Changes with diff

Exercise

Staged changes.

git diff 

Reading the Log

Exercise

Compact log.

git log 

The .gitignore File

Exercise

Ignore logs.

echo "" > .gitignore

Amending the Last Commit

Exercise

Change last commit.

git commit  -m "new"

Discarding Changes

Exercise

Discard changes.

git  a.txt

Looking Inside a Commit

Exercise

Parent of HEAD.

HEAD1

Lightweight Tags

Exercise

Create a tag.

git  v1.0

Renaming and Moving

Exercise

Rename.

git  old new

Staging Parts with add -p

Exercise

Interactive hunks.

git add 

Empty Commits and Messages

Exercise

Allow no changes.

git commit ---empty -m x

Aliases

Exercise

Define an alias.

git config alias.co 

Configuring Git

Exercise

Read a setting.

git config  user.name

Getting Help

Exercise

Short usage flag.

git status 

Looking at Old Versions

Exercise

File at old commit.

git show HEAD~1a.txt

Finding Changes with log -S

Exercise

Search history.

git log  text

Comparing Branches

Exercise

Changed names.

git diff  a b

Cherry Pick

Exercise

Copy a commit.

git  commit

Squash Merge

Exercise

Squash.

git merge  feat

Rebase Basics

Exercise

Replay commits.

git  main

Graph View

Exercise

Draw branches.

git log 

Bare Repositories

Exercise

Server style repo.

git init 

A Daily Solo Workflow

Exercise

Delete the finished branch.

git branch  feat

Practice: Make a Release

Exercise

Annotated tag.

git tag  v1 -m x

Practice: Undo a Mistake

Exercise

Undo commit.

git  HEAD

Practice: Feature and Merge

Exercise

Merge.

git merge 

Log Formats

Exercise

Limit to one commit.

git log - 1

Filtering the Log

Exercise

Search messages.

git log --="fix"

Inspecting a Commit

Exercise

List changed file names.

git show --name- HEAD

Blame: Who Changed This Line

Exercise

Show line authors.

git  a.txt

Diff Variants

Exercise

See staged changes.

git diff 

Shortlog and git grep

Exercise

Search tracked files.

git  hello

Restore and Unstage

Exercise

Unstage a file.

git restore  a.txt

Reset: Soft, Mixed and Hard

Exercise

Keep changes staged.

git reset  HEAD~1

Revert: Undo Safely

Exercise

Undo a commit safely.

git  HEAD

Clean Untracked Files

Exercise

Dry run.

git clean 

Stash In Depth

Exercise

Stash with a name.

git stash push  "wip"

reset --soft and --mixed

Exercise

Keep staged.

git reset  HEAD~1

reset --hard

Exercise

Discard everything.

git reset  HEAD

Revert a Commit

Exercise

Undo safely.

git  HEAD

Cleaning Untracked Files

Exercise

Dry run.

git clean 

Stashing Work

Exercise

Bring stash back.

git stash 

Stash List and Names

Exercise

Name a stash.

git stash push  "name"

The Reflog Safety Net

Exercise

List movements.

git 

Fix a Forgotten File

Exercise

Keep message.

git commit --amend 

Branches

Exercise

Create and switch to a branch.

git switch  feature

Merging

Exercise

Merge feature into the current branch.

git  feature

Merge Conflicts

Exercise

Cancel a merge.

git merge 

Tags and Stash

Exercise

Bring back stashed work.

git stash 

Managing Branches

Exercise

Delete a merged branch.

git branch  feat

Switch Branches

Exercise

Create and switch.

git switch  work

Fast-forward and Merge Commits

Exercise

Always create a merge commit.

git merge  f2

Aborting a Merge

Exercise

Cancel a merge.

git merge 

Annotated Tags and Describe

Exercise

Create an annotated tag.

git tag  v1.0 -m "msg"

Worktrees: Several Branches at Once

Exercise

Add a worktree.

git worktree  ../wt

Creating Branches

Exercise

New branch.

git switch  feature

Switching Branches

Exercise

Go to main.

git switch 

Renaming and Deleting Branches

Exercise

Delete merged.

git branch  topic

Fast Forward Merge

Exercise

Merge a branch.

git  feat

Merge Commits

Exercise

Always merge commit.

git merge  feat

Resolving a Conflict

Exercise

Mark resolved.

git  a.txt

Aborting a Merge

Exercise

Cancel.

git merge 

Listing and Comparing Branches

Exercise

Merged branches.

git branch 

Branch Naming

Exercise

List by pattern.

git branch --list ""

Detached HEAD

Exercise

Keep detached work.

git switch  name

Getting a File from Another Commit

Exercise

Source commit.

git restore -- HEAD~1 f

Remotes: clone, push and pull

Exercise

Upload commits.

git  origin main

GitHub Flow

Exercise

Ask for review before merging.

git push -u origin fix, then open a  request

Working With a Remote

Exercise

Add a remote.

git remote  origin url

Fetch versus Pull

Exercise

Download without merging.

git 

Submodules

Exercise

Add a submodule.

git submodule  url path

Pull Requests and Forks

Exercise

Name the original remote.

git remote add  url

Cloning

Exercise

Copy a repository.

git  url

Adding a Remote

Exercise

Add a remote.

git remote  origin url

Upstream and Tracking

Exercise

Short with branch.

git status 

Remote Branches

Exercise

List remote.

git branch 

Deleting Remote Branches

Exercise

Remove remote branch.

git push origin  old

Pull Request Flow

Exercise

New feature branch.

git switch -c 

Pushing Tags

Exercise

Push all tags.

git push 

Push and Pull

Exercise

Download and merge.

git 

fetch Without Merging

Exercise

Download only.

git 

Rebase

Premium exercise. See plans

Cherry-pick and Reset

Premium exercise. See plans

Reflog and Bisect

Premium exercise. See plans

Hooks, Aliases and Good Habits

Premium exercise. See plans

Squashing Commits

Premium exercise. See plans

Fixup and Autosquash

Premium exercise. See plans

Rebase --onto

Premium exercise. See plans

Reflog: Recover Lost Commits

Premium exercise. See plans

Bisect: Find the Bad Commit

Premium exercise. See plans

Hooks: Block Bad Commits

Premium exercise. See plans

Aliases and Config Tricks

Premium exercise. See plans

.gitattributes and Line Endings

Premium exercise. See plans

Shallow and Partial Clones

Premium exercise. See plans

Notes and Archive

Premium exercise. See plans

Debugging .gitignore

Premium exercise. See plans

Detached HEAD

Premium exercise. See plans

Branching Strategies

Premium exercise. See plans

Keeping Secrets Out of Git

Premium exercise. See plans

Git with CI and Code Review

Premium exercise. See plans

Troubleshooting Common Problems

Premium exercise. See plans