Alin Li Git

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

v1.0 • Open Source Education
📝

1. ما Git؟

▼

Git is a free, open-source version control system. يتتبّع كل تغيير تجريه على ملفاتك، لتتمكّن دائمًا من الرجوع إلى إصدار سابق إذا حدث خطأ.

It was created in 2005 by Linus Torvalds، وهو الشخص نفسه الذي أنشأ Linux! يُعد Git أكثر أنظمة التحكم بالإصدارات استخدامًا في العالم.

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. لماذا تستخدم Git؟

▼

Git solves some very common problems that every developer faces:

Without Git (The Old Way)

كان الناس يحفظون الملفات بهذه الطريقة: project_v1.zip, project_v2_final.zip, project_v2_final_REALLY_final.zip... كان الأمر فوضويًا ومربكًا!

With Git, you get:

⏪
Undo Mistakes
Go back to any previous version
👥
Teamwork
يمكن لكثيرين العمل على المشروع نفسه
📋
History
See who changed what and when
🔀
Branches
Try new ideas without breaking things
⬇️

3. تثبيت Git

▼

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

🐧

Linux (Ubuntu / Debian)

افتح الطرفية واكتب:

$ 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

افتح الطرفية واكتب:

$ git --version

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

Check if Git is Installed

افتح الطرفية واكتب git --version. إذا ظهر رقم إصدار، فأنت جاهز!

$ git --version git version 2.45.2
⚙️

4. الإعداد لأول مرة

▼

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

# اضبط اسمك $ git config --global user.name «اسمك» # اضبط بريدك الإلكتروني $ git config --global user.email "your.email@example.com" # تحقّق من إعداداتك $ 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. سير العمل في Git (المناطق الـ 3)

▼

Git has 3 مناطق مهمة where your files live. Understanding these is the key to understanding Git!

The Three Areas of Git
📁 مجلد العمل
→
📋 منطقة التجهيز
→
💾 المستودع
Your files on disk
Ready to commit
Saved history
git add →
git commit →
تشبيه: تجهيز حقيبة سفر!

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

# أنشئ مستودع Git جديدًا $ git init # أو نزّل مشروعًا موجودًا $ git clone https://github.com/user/project.git

إجراء تغييرات

# تحقّق من الملفات التي تغيرت $ git status # أضف ملفًا محددًا إلى منطقة التجهيز $ git add filename.txt # أضف كل الملفات المعدّلة إلى منطقة التجهيز $ git add . # احفظ (سجّل التغييرات) مع رسالة $ git commit -m «إضافة ميزة جديدة»

Viewing History

# اعرض قائمة بكل تسجيلات التغييرات $ git log # اعرض نسخة مختصرة من السجل $ git log --oneline # اعرض ما تغيّر في الملفات $ git diff
Good Commit Messages!

اكتب دائمًا رسائل إيداع واضحة تشرح what you changed and why. قارن بين هذه الأمثلة:

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

Commit History Timeline
a3f2b1c
إضافة قائمة تنقل
أحمد — منذ ساعتين
e7d4c2a
Fix homepage layout
Fatima — 5 hours ago
b1a9f3e
Create project structure
أحمد — منذ يوم
f0e2d4b
Initial commit
أحمد — منذ يومين
🌿

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. إذا نما الفرع جيدًا، يمكنك دمجه مجددًا بالجذع. وإلا فيمكنك ببساطة قطعه!

main feature merge!
# اعرض كل الفروع $ git branch # أنشئ فرعًا جديدًا $ git branch feature-navbar # انتقل إلى ذلك الفرع $ git checkout feature-navbar # أنشئ وانتقل بأمر واحد $ git checkout -b feature-navbar # عُد إلى الفرع main $ git checkout main # ادمج الميزة في main $ git merge feature-navbar # احذف فرعًا (بعد الدمج) $ git branch -d feature-navbar
تعارضات الدمج!

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. عليك اختيار التغييرات التي تريد الاحتفاظ بها يدويًا، ثم تسجيل النتيجة.

☁️

8. Remote Repositories & GitHub

▼

So far, everything has been on your computer (محليًا). لكن ماذا لو أردت:

• 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، و Codeberg (مفتوح المصدر!).

محلي ↔ بعيد
💻 حاسوبك
مستودع محلي
git push →
← git pull
☁️ GitHub
Remote Repo
# اربط مستودعك المحلي بمستودع بعيد $ git remote add origin https://github.com/user/project.git # ارفع إيداعاتك (push) إلى GitHub $ git push -u origin main # نزّل التغييرات الجديدة (pull) من GitHub $ git pull origin main # نزّل مشروعًا من GitHub $ git clone https://github.com/user/project.git
بدائل مفتوحة المصدر!

While GitHub is the most popular, there are great open-source alternatives like Codeberg (codeberg.org) و 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 — طرفية Git
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. لعبة المطابقة

▼

Drag each Git command to its correct description!

Commands

What It Does

🃏

11. بطاقات تعليمية

▼

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

📁
Repository
Click to flip!
مجلد يتتبعه Git. يحتوي على جميع ملفات مشروعك وتاريخه وفروعه.
💾
Commit
Click to flip!
لقطة لمشروعك في لحظة محددة. مثل «نقطة حفظ» في لعبة.
🌿
Branch
Click to flip!
نسخة منفصلة من مشروعك يمكنك العمل فيها دون التأثير في الشيفرة الرئيسية.
📋
Staging Area
Click to flip!
The "waiting room" where you prepare files before committing them.
🔀
دمج
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!
إنشاء نسخة كاملة من مستودع بعيد على حاسوبك المحلي.
📝

12. الاختبار النهائي

▼

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

📌

13. مرجع Git سريع

▼

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
اعرض جميع الفروع
git branch <name>
Create a new branch
git checkout <branch>
Switch to a branch
git checkout -b <name>
Create + switch branch
git merge <branch>
ادمج الفرع في الفرع الحالي
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