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 आपके कमिट को दूसरी ब्रांच के ऊपर फिर चलाता है, जिससे लीनियर इतिहास बनता है पर कमिट ID बदल जाते हैं।
किसी कमिट को अनडू कैसे करें?
'git revert <कमिट>' चलाएँ, जो बदलाव पलटने वाला नया कमिट जोड़ता है (सुरक्षित, शेयर किया गया इतिहास बरकरार)। 'git reset' इतिहास राइट करता है, इसे शेयर ब्रांच पर न चलाएँ।
git pull और git fetch में अंतर?
fetch रिमोट से कमिट और रेफ़ बिना वर्किंग ट्री छुए डाउनलोड करता है। pull पहले fetch करता है, फिर उन बदलावों को मर्ज या रीबेस करके मौजूदा ब्रांच में लाता है।
git stash कब इस्तेमाल करें?
stash अनकमिट बदलावों को अस्थायी रूप से अलग रखता है ताकि आप स्वच्छ रूप से ब्रांच बदल या pull कर सकें, बाद में 'git stash pop' से वापस लाएँ।