1. What is Git?
โผGit is a free, open-source version control system. It keeps track of every change you make to your files, so you can always go back to an earlier version if something goes wrong.
It was created in 2005 by Linus Torvalds, the same person who created Linux! Git is the most popular version control system in the world.
Imagine you're writing a story. Every time you finish a chapter, you take a photo (snapshot) of the whole notebook. If you make a mistake later, you can look back at any photo to see what the story looked like before. Git does the same for your code and files!
In a video game, you save your progress at certain points. If your character dies, you restart from the last save. In Git, every time you "commit," you create a save point for your project!
The name "Git" is British slang for a silly person. Linus Torvalds joked that he names his projects after himself!
2. Why Use Git?
โผGit solves some very common problems that every developer faces:
People used to save files like: project_v1.zip, project_v2_final.zip, project_v2_final_REALLY_final.zip... It was messy and confusing!
With Git, you get:
Go back to any previous version
Many people can work on the same project
See who changed what and when
Try new ideas without breaking things
3. Installing Git
โผGit works on all operating systems. Here's how to install it:
Linux (Ubuntu / Debian)
Open the Terminal and type:
Windows
Download from git-scm.com and run the installer. Keep all the default settings. This gives you "Git Bash" โ a special terminal for Git.
macOS
Open the Terminal and type:
If Git is not installed, macOS will ask you to install it.
Open your terminal and type git --version. If it shows a version number, you're ready!
4. First Time Setup
โผBefore using Git, you need to tell it who you are. This information appears in every commit you make.
--global means this setting applies to ALL your projects on this computer. You only need to do this once!
5. Git Workflow (The 3 Areas)
โผGit has 3 important areas where your files live. Understanding these is the key to understanding Git!
Working Directory = Your room with clothes everywhere.
Staging Area = The pile of clothes you've chosen to pack.
Repository = The locked suitcase, safely stored.
git add = picking clothes from your room โ pile.
git commit = putting the pile into the suitcase and locking it.
6. Essential Git Commands
โผStarting a Project
Making Changes
Viewing History
Always write clear commit messages that explain what you changed and why. Compare these:
โ "fix stuff" โ vague, unhelpful
โ
"Fix login button not working on mobile" โ clear and useful!
7. Branches
โผA branch is like a separate copy of your project where you can try new things without affecting the main code.
Think of a tree. The trunk is your main project (called main branch). When you want to try something new, you grow a branch. If the branch grows well, you can merge it back to the trunk. If not, you can just cut it off!
Sometimes two people change the same line in the same file. Git can't decide which version to keep โ this is called a merge conflict. You need to manually choose which changes to keep, then commit the result.
8. Remote Repositories & GitHub
โผSo far, everything has been on your computer (local). But what if you want to:
โข Share your code with others?
โข Have a backup in the cloud?
โข Work on the project from another computer?
That's where remote repositories come in! Popular hosting services include GitHub, GitLab, and Codeberg (open source!).
Local Repo
Remote Repo
While GitHub is the most popular, there are great open-source alternatives like Codeberg (codeberg.org) and Gitea that you can even host yourself!
9. Try It Out! (Interactive Terminal)
โผType Git commands below and see what happens! Try commands like: git init, git status, git add, git commit, git log, git branch
10. Matching Game
โผDrag each Git command to its correct description!
Commands
What It Does
11. Flashcards
โผClick each card to flip it and learn what each term means!
12. Final Quiz
โผTest your knowledge! Choose the correct answer for each question.
13. Git Cheat Sheet
โผKeep this handy! These are the most important Git commands you'll use: