مرجع مدمج لطريقة عمل Git في السطر: إنشاء الفروع، المزامنة مع الـ remote، والتراجع دون كسر عمل الفريق.
الهوية (مرة واحدة)
git config --global user.name "الاسم"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
مشروع جديد أو استنساخ
git init
git clone https://github.com/org/repo.git
cd repo
الفروع والتبديل
git branch
git switch -c feature/login
git switch main
git branch -d feature/login
إضافة وتثبيت ورفع
git status
git add -p
git commit -m "وصف التغيير"
git push -u origin feature/login
المزامنة مع الخادم
git fetch origin
git pull --rebase origin main
git push
السجل والبحث
git log --oneline -n 20
git log --graph --oneline --all -n 30
git blame -L 10,40 path/to/file
إرجاع غير مدمج / إلغاء مرحلة
git restore path/to/file
git restore --staged path
Stash عند تبديل المهمة
git stash push -m "wip"
git stash list
git stash pop
تلميح أمان
git reflogلاستعادة commits بعد reset مؤسف.- على الفروع المشتركة يُفضّل
git <revert>بدلاً من إعادة كتابة التاريخ. - إن اضطررت لدفع قوي:
git push --force-with-lease.
الأوامر داخل الشرطات تبقى LTR لسهولة القراءة.