Alin Li Git

Learn version control the fun and easy way! Track your code changes like a pro.

v1.0 • Open Source Education
📝

1. Mis on Git?

▼

Git is a free, open-source version control system. See jälgib iga failides tehtud muudatust, et saaksid vea korral alati naasta varasema versiooni juurde.

It was created in 2005 by Linus Torvalds, sama inimene, kes lõi Linuxi! Git on maailma populaarseim versioonihaldussüsteem.

Real-Life Analogy: The Time Machine!

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!

Another Analogy: Save Points in Video Games!

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!

Fun Fact!

The name "Git" is British slang for a silly person. Linus Torvalds joked that he names his projects after himself!

💡

2. Miks kasutada Git'i?

▼

Git solves some very common problems that every developer faces:

Without Git (The Old Way)

Varem salvestasid inimesed faile nii: project_v1.zip, project_v2_final.zip, project_v2_final_REALLY_final.zip... See oli segane ja kaootiline!

With Git, you get:

⏪
Undo Mistakes
Go back to any previous version
👥
Teamwork
Paljud saavad sama projektiga töötada
📋
History
See who changed what and when
🔀
Branches
Try new ideas without breaking things
⬇️

3. Giti paigaldamine

▼

Git works on all operating systems. Here's how to install it:

🐧

Linux (Ubuntu / Debian)

Ava terminal ja sisesta:

$ sudo apt update $ sudo apt install git
🪟

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

Ava terminal ja sisesta:

$ git --version

If Git is not installed, macOS will ask you to install it.

Check if Git is Installed

Ava terminal ja sisesta git --version. Kui kuvatakse versiooninumber, oled valmis!

$ git --version git version 2.45.2
⚙️

4. Esmane seadistamine

▼

Before using Git, you need to tell it who you are. This information appears in every commit you make.

# Määra oma nimi $ git config --global user.name „Sinu nimi“ # Määra oma e-posti aadress $ git config --global user.email "your.email@example.com" # Kontrolli oma seadeid $ git config --list
What does --global mean?

--global means this setting applies to ALL your projects on this computer. You only need to do this once!

🔄

5. Giti töövoog (3 ala)

▼

Git has 3 olulist ala where your files live. Understanding these is the key to understanding Git!

The Three Areas of Git
📁 Töökataloog
→
📋 Lavastusala
→
💾 Hoidla
Your files on disk
Ready to commit
Saved history
git add →
git commit →
Võrdlus: kohvri pakkimine!

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

# Loo uus Giti hoidla $ git init # Või laadi alla olemasolev projekt $ git clone https://github.com/user/project.git

Muudatuste tegemine

# Kontrolli, millised failid on muutunud $ git status # Lisa kindel fail ettevalmistusalasse $ git add filename.txt # Lisa KÕIK muudetud failid ettevalmistusalasse $ git add . # Salvesta muudatused (commit) koos sõnumiga $ git commit -m „Lisa uus funktsioon“

Viewing History

# Vaata kõigi muudatuskinnituste loendit $ git log # Vaata logi lühiversiooni $ git log --oneline # Vaata, mis failides muutus $ git diff
Good Commit Messages!

Kirjuta alati selged sissekandeteated, mis selgitavad what you changed and why. Võrdle neid:

❌ "fix stuff" — vague, unhelpful
✅ "Fix login button not working on mobile" — clear and useful!

Commit History Timeline
a3f2b1c
Lisa navigeerimismenüü
Ahmed — 2 tundi tagasi
e7d4c2a
Fix homepage layout
Fatima — 5 hours ago
b1a9f3e
Create project structure
Ahmed — 1 päev tagasi
f0e2d4b
Initial commit
Ahmed — 2 päeva tagasi
🌿

7. Branches

▼

A branch is like a separate copy of your project where you can try new things without affecting the main code.

Võrdlus: puu!

Think of a tree. The trunk is your main project (called main branch). When you want to try something new, you grow a branch. Kui haru kasvab hästi, saad selle tüvega tagasi liita. Kui mitte, võid selle lihtsalt maha lõigata!

main feature merge!
# Vaata kõiki harusid $ git branch # Loo uus haru $ git branch feature-navbar # Lülitu sellele harule $ git checkout feature-navbar # Loo JA vaheta ühe käsuga $ git checkout -b feature-navbar # Mine tagasi main-harule $ git checkout main # Ühenda funktsioon main-harusse $ git merge feature-navbar # Kustuta haru (pärast ühendamist) $ git branch -d feature-navbar
Ühendamiskonfliktid!

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. Pead käsitsi valima, millised muudatused alles jätta, ning seejärel tulemuse kinnitama.

☁️

8. Remote Repositories & GitHub

▼

So far, everything has been on your computer (kohalikult). Aga kui tahad:

• 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, ja Codeberg (avatud lähtekoodiga!).

Kohalik ↔ Kaughoidla
💻 Sinu arvuti
Kohalik hoidla
git push →
← git pull
☁️ GitHub
Remote Repo
# Ühenda oma kohalik hoidla kaugrepositooriumiga $ git remote add origin https://github.com/user/project.git # Laadi oma muudatuskanded GitHubi (push) $ git push -u origin main # Laadi GitHubist alla uued muudatused (pull) $ git pull origin main # Laadi projekt GitHubist alla $ git clone https://github.com/user/project.git
Avatud lähtekoodiga alternatiivid!

While GitHub is the most popular, there are great open-source alternatives like Codeberg (codeberg.org) ja 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

Alin Li Giti terminal
Welcome to Alin Li Git Simulator! Type a git command and press Enter.
Try: git init, git status, git add, git commit, git log, git branch, git help
$
🎯

10. Sobitamismäng

▼

Drag each Git command to its correct description!

Commands

What It Does

🃏

11. Mälukaardid

▼

Click each card to flip it and learn what each term means!

📁
Repository
Click to flip!
Kaust, mida Git jälgib. Sisaldab kõiki projekti faile, ajalugu ja harusid.
💾
Commit
Click to flip!
Projekti hetkeseis kindlal ajahetkel. Nagu mängu salvestuspunkt.
🌿
Branch
Click to flip!
Projekti eraldi versioon, kus saad töötada põhikoodi mõjutamata.
📋
Staging Area
Click to flip!
The "waiting room" where you prepare files before committing them.
🔀
Ühenda
Click to flip!
Combining changes from one branch into another. Like mixing two sets of changes together.
⬆️
Push
Click to flip!
Uploading your local commits to a remote repository (like GitHub).
⬇️
Pull
Click to flip!
Downloading new changes from a remote repository to your local computer.
📝
Clone
Click to flip!
Kaughoidlast täieliku koopia tegemine kohalikku arvutisse.
📝

12. Lõputest

▼

Test your knowledge! Choose the correct answer for each question.

📌

13. Giti spikker

▼

Keep this handy! These are the most important Git commands you'll use:

git init
Start a new Git repository
git clone <url>
Copy a remote repository
git status
See what files have changed
git add <file>
Stage a file for commit
git add .
Stage ALL changed files
git commit -m "msg"
Save staged changes
git log
View commit history
git log --oneline
Short version of log
git diff
See what changed in files
git branch
Kuva kõik harud
git branch <name>
Create a new branch
git checkout <branch>
Switch to a branch
git checkout -b <name>
Create + switch branch
git merge <branch>
Ühenda haru praegusesse
git remote add origin <url>
Connect to remote repo
git push
Upload commits to remote
git pull
Download changes from remote
git stash
Temporarily save changes