Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: DSA in Python
Stage 5: Specialization

Part 11 / Topic 11 of 12

Git and GitHub basics

Git is a version control tool: it saves snapshots (called commits) of your project, so you can see what changed and go back. GitHub is a website that stores a copy of your Git project online (a remote) and helps teams work together. Like the "save game" points in a video game, plus a cloud backup.

Everyday commands

git init                         # start tracking this folder (once)
git status                       # what changed? what is staged?
git add shop.py                  # stage one file for the next commit
git add .                        # stage everything that changed
git commit -m "Add cart total"   # save a snapshot with a short message
git log --oneline                # list commits, one per line
git diff                         # see changes not staged yet

Staging (git add) means choosing which changes go into the next commit.

Branches

A branch is a separate line of work, so you can try something without breaking main.

git branch                       # list branches (* marks the current one)
git switch -c add-gst-tests      # create a new branch and move to it
git switch main                  # go back to main

Pushing to GitHub

Create an empty repository on GitHub first, then:

git remote add origin https://github.com/<your-username>/<repo-name>.git
git push -u origin main          # first push; later just: git push
git pull                         # get the latest commits from GitHub

.gitignore

A file named .gitignore lists files Git should never track:

.venv/
__pycache__/
.pytest_cache/
*.log
demo_*
.env

Never commit passwords or API keys (for example in a .env file).

The pull request idea

A pull request (PR) is a request on GitHub to merge your branch into main.

  1. Create a branch, commit your work, git push -u origin <branch>.
  2. Open a pull request on GitHub.
  3. Teammates review the changes; automatic checks (tests, Ruff) run.
  4. When everything is green and approved, the branch is merged into main.

Done here? The practice set for Part 11 — 7 exercises with solutions — is on the part page.

Search the guide