Codzy

Git and GitHub

Git is a version control tool: it keeps the history of every change in a project, lets you go back in time and lets several people work together without overwriting each other. The basic commands are typed in a terminal: git init (start), git add (stage files), git commit -m "message" (save a snapshot) and git status (see where you are).

GitHub is a website that hosts Git projects online: git push sends your commits there, and git pull fetches other people's. The .gitignore file lists the files Git must ignore, like __pycache__/, .venv/ or *.log files. Your GitHub is also your portfolio for recruiters!

# Git commands are typed in a terminal, not in Python:
#   git init                -> start tracking a project
#   git add main.py         -> prepare a file for the next snapshot
#   git commit -m "message" -> save a snapshot (a commit)
#   git push                -> send your commits to GitHub

with open(".gitignore", "w") as f:
    f.write("__pycache__/\n.venv/\n*.log\n")

with open(".gitignore") as f:
    print(f.read())

Start the lesson