דף כיסום לפקודות Git

Git עוקב אחרי השינויים בקבצים שלך כסדרת קומיטים במאגר. הפקודות האלו מכסות את זרימת העבודה היומיומית: יצירת מאגר, שמירת עבודה, הסתעפות, מיזוג ושיתוף עם מרוחק. השאר את הדף פתוח בזמן הלמידה.

עודכן:

פקודהמה היא עושה
git initCreate a new, empty Git repository in the current directory.
git cloneDownload a remote repository and its full history to your machine.
git statusShow changed, staged and untracked files in the working tree.
git addStage changes (files) to be included in the next commit.
git commitRecord staged changes as a new commit with a message.
git logDisplay the commit history of the repository.
git diffShow unstaged or staged differences between states.
git branchList, create or delete branches in the repository.
git checkout / switchSwitch branches or restore files (switch is the modern command).
git mergeJoin another branch's history into the current branch.
git rebaseReapply commits on top of another base commit, rewriting history.
git pullFetch from a remote and merge the changes into the current branch.
git pushUpload local commits to a remote repository.
git stashTemporarily shelve uncommitted changes to reapply later.
git remoteManage the set of remote repositories you track.

הערות

שאלות נפוצות

מה ההבדל בין merge ל-rebase?
Merge משלב היסטוריות עם קומיט חדש בעל שני הורים. Rebase מנגן מחדש את הקומיטים שלך מעל ענף אחר, ויוצר היסטוריה לינארית אך כותב מחדש את מזהי הקומיט.
איך מבטלים קומיט?
השתמש ב-'git revert <commit>' כדי להוסיף קומיט חדש שמבטל את השינוי (בטוח, שומר על ההיסטוריה המשותפת). 'git reset' כותב מחדש את ההיסטוריה ולא אמור לשמש על ענפים משותפים.
מה ההבדל בין git pull ל-git fetch?
Fetch מוריד קומיטים ורפרנסים מרחוק מבלי לגעת בעץ העבודה שלך. Pull מבצע fetch ואז ממזג או עושה rebase של השינויים האלה לענף הנוכחי שלך.
מתי כדאי להשתמש ב-git stash?
Stash מניח בצד זמנית שינויים שלא קומיטו כדי שתוכל להחליף ענף או למשוך נקי, ואז משחזר אותם ב-'git stash pop'.