Setup25 min+50 XP

Git and GitHub

A save system for code. Go back in time, see every change, and back up your work online.

0% done
TASK 1

Learn it

Key idea

Git saves snapshots called commits. GitHub keeps a copy online.

Key words
your computer: the repositoryWorking folderyou edit filesStaging areachanges readyto saveCommitssaved snapshotsGitHubonline copygit addgit commitgit push
Changes move from your folder to staging, to a commit, then to GitHub.

Git is a version control system: it takes snapshots of your project called commits. Each commit has a message saying what changed. If you break something, you can look back at, or return to, any earlier commit. Almost every software team in the world uses Git.

The everyday cycle has three steps: change files, stage the changes you want to save (git add), then commit them with a message (git commit -m "..."). A folder tracked by Git is called a repository (repo).

GitHub is a website that stores copies of Git repositories online, so your work is backed up and you can share it. Uploading commits is called pushing. VS Code can publish to GitHub with one button.

Real life linkGit is like save points in a game. If the boss fight goes wrong, you load the last save. If your code breaks, you go back to the last commit.
  1. Install Git:
    sudo apt install -y git
  2. Check it worked:
    git --version
    You should see something like
    git version 2.43.0
  1. Tell Git your name and email once. These appear on your commits (on all systems):
    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
  2. In your vault_breaker folder, turn it into a repository:
    git init
  3. Tell Git to ignore the virtual environment (it is big and can be rebuilt from requirements.txt). Create a file called .gitignore in VS Code containing this line:
    .venv/
  4. Stage everything and make your first commit:
    git add .
    git commit -m "First commit: hello.py and setup"
  5. See your history:
    git log --oneline
    You should see something like
    3f9a1c2 First commit: hello.py and setup
  6. Back it up on GitHub (optional, and only if you are old enough): GitHub requires users to be at least 13. Create a free account at github.com with an adult's help. Then in VS Code open the Source Control panel (the branch icon) and click Publish to GitHub. Choose a private repository. VS Code opens your browser to sign in and then uploads your commits.
    Under 13? Skip GitHub for now. Git on your own computer still gives you the full save system.
TASK 2

Capture the flag

+10 XP

Which Git command saves a snapshot of your staged changes? (just the command word after git)

Create a free account to start this lab

Sign in to answer the flag question. Your progress, XP and code are saved to your account. No card needed.

HOMEWORK

Version control online

+20 XP

Set up Git for your game project.

Create a free account to start this lab

Sign in to do this homework and have it checked. Your progress, XP and code are saved to your account. No card needed.