git add
מכין שינויים ל-commit (מעביר ל-"staging area").
git add . # הכל
git add [קובץ] # קובץ ספציפי
git add [תיקייה]/ # תיקייה שלמה
git add -p # בחירה אינטראקטיבית חלקיתgit branch
מנהל ענפים — רשימה, יצירה, מחיקה.
git branch # רשימת ענפים מקומיים
git branch -a # מקומיים + remote
git branch [שם] # יצירת ענף חדש (לא עובר אליו)
git branch -d [שם] # מחיקה בטוחה (אחרי merge)git checkout / git switch
מעבר בין ענפים.
# מודרני (Git 2.23+) — מומלץ
git switch [branch] # עבור לענף קיים
git switch -c feature/x # צור + עבור
git commit
שומר snapshot של השינויים הנוכחיים בהיסטוריית הפרויקט.
git commit [-m "הודעה"] [--amend] [--no-edit] [-a]git diff
מראה בדיוק מה השתנה — שורה אחר שורה.
git diff # שינויים לא staged
git diff --staged # שינויים staged (אחרי add)
git diff HEAD # הכל מאז commit אחרון
git diff [branch1] [branch2] # הבדל בין ענפיםgit init
יוצר repository Git חדש בתיקייה הנוכחית.
git init
git init [שם-תיקייה]git log
מציג היסטוריית commits.
git log # מלא
git log --oneline # קצר — שורה אחת לcommit
git log --oneline -10 # 10 אחרונים
git log --oneline --graph # עם ויזואליזציה של branchesgit merge
משלב ענף אחד לתוך אחר.
git merge [branch] # merge לענף הנוכחי
git merge --no-ff [branch] # שמור תמיד merge commit
git merge --squash [branch] # דחס הכל לcommit אחד
git merge --abort # בטל merge תקועgit pull
מושך עדכונים מהשרת ומשלב אותם לקוד המקומי.
git pull # משוך לbranch הנוכחי
git pull origin [branch] # מפורש
git pull --rebase # משוך + rebase במקום mergegit push
שולח commits מקומיים לשרת (GitHub/GitLab).
git push # push לbranch הנוכחי
git push origin [branch] # push מפורש
git push -u origin [branch] # push + הגדר כברירת מחדל
git push origin --tags # שלח גם tagsgit remote
מנהל חיבורים לשרתים חיצוניים (GitHub, GitLab וכו').
git remote -v # הצג remotes קיימים
git remote add origin [URL] # הוסף remote
git remote remove origin # הסר remote
git remote set-url origin [URL] # שנה URLgit reset / git revert
מזיז את HEAD אחורה בהיסטוריה.
git reset HEAD~1 # בטל commit אחרון (שמור קוד)
git reset HEAD~1 --soft # בטל commit, השאר staged
git reset HEAD~1 --hard # בטל commit + מחק קוד ⚠️
git reset HEAD [קובץ] # הסר קובץ מ-staginggit stash
שומר שינויים זמנית בצד — בלי commit.
git stash # שמור הכל
git stash save "תיאור" # עם תיאור
git stash list # רשימת stashes
git stash pop # שחזר + מחקgit status
מראה מה השתנה — מה staged, מה לא, מה לא עקוב.
git status
git status -s # קצר — שורה אחת לקובץgit tag
מסמן נקודה ספציפית בהיסטוריה — בדרך כלל גרסה.
git tag # רשימת tags
git tag v1.0.0 # tag פשוט
git tag -a v1.0.0 -m "תיאור" # tag עם הודעה (מומלץ)
git push origin --tags # שלח tags לשרת