TL
Tool Lab
💰Donate
💰Donate

Git Commands Cheat Sheet

Comprehensive Git command reference organized by workflow.

Setup & Config

git config --global user.name "Name"Set global username
git config --global user.email "email"Set global email
git config --listList all config settings
git initInitialize a new local repository
git clone <url>Clone a remote repository

Staging & Committing

git statusShow working tree status
git add <file>Stage a specific file
git add .Stage all changes
git commit -m "message"Commit staged changes with a message
git commit --amendModify the last commit
git diffShow unstaged changes
git diff --stagedShow staged changes

Branching

git branchList all local branches
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to a new branch
git switch <branch>Switch to a branch (modern)
git switch -c <branch>Create and switch to a new branch (modern)
git branch -d <branch>Delete a merged branch
git branch -D <branch>Force-delete a branch
git merge <branch>Merge a branch into current branch
git rebase <branch>Rebase current branch onto another

Remote Repositories

git remote -vList remote connections
git remote add origin <url>Add a remote named origin
git fetchDownload remote changes without merging
git pullFetch and merge remote changes
git pull --rebaseFetch and rebase instead of merge
git push origin <branch>Push branch to remote
git push -u origin <branch>Push and set upstream tracking
git push --force-with-leaseSafe force push (checks remote)

History & Log

git logShow commit history
git log --oneline --graphCompact branch graph
git log -n 10Show last 10 commits
git log --author="name"Filter commits by author
git blame <file>Show who changed each line
git show <commit>Show details of a specific commit

Undoing Changes

git restore <file>Discard unstaged changes in a file
git restore --staged <file>Unstage a file
git reset HEAD~1Undo last commit, keep changes staged
git reset --soft HEAD~1Undo last commit, keep changes
git reset --hard HEAD~1Undo last commit, discard changes
git revert <commit>Create a new commit that undoes a commit
git stashStash uncommitted changes
git stash popApply and remove latest stash
git stash listList all stashes

Tags

git tagList all tags
git tag v1.0.0Create a lightweight tag
git tag -a v1.0.0 -m "Release"Create an annotated tag
git push origin --tagsPush all tags to remote
git tag -d v1.0.0Delete a local tag

इस टूल के बारे में

Git कमांड संदर्भ सात श्रेणियों में आवश्यक Git कमांड का त्वरित खोज सूचकांक प्रदान करता है: सेटअप, स्टेजिंग और कमिट, ब्रांचिंग, रिमोट, इतिहास, परिवर्तन पूर्ववत करना और टैग।

कमांड नाम या विवरण द्वारा तुरंत फ़िल्टर करने के लिए खोज बॉक्स का उपयोग करें। इस पेज को बुकमार्क करें और जब त्वरित सिंटैक्स अनुस्मारक की आवश्यकता हो तब वापस आएं।

कैसे उपयोग करें

  1. खोज बॉक्स में कमांड नाम या कीवर्ड टाइप करें (जैसे commit, branch, remote)।
  2. मेल खाने वाली कमांड वास्तविक समय में श्रेणी के अनुसार फ़िल्टर की जाती हैं।
  3. कमांड और उसके विवरण की समीक्षा करें।
  4. पूरी सूची पुनर्स्थापित करने के लिए खोज बॉक्स साफ़ करें।

उपयोग के मामले

डेवलपर ब्राउज़र छोड़े बिना Git कमांड सिंटैक्स को जल्दी याद करने के लिए उपयोग करते हैं। Git सीखते समय शुरुआती लोग श्रेणी संरचना से लाभ उठाते हैं। कोड रिव्यू के दौरान किसी विशिष्ट git ऑपरेशन को जल्दी खोजने के लिए उपयोगी।

अक्सर पूछे जाने वाले प्रश्न

  • कमांड विवरण अंग्रेज़ी में क्यों हैं?Git कमांड और फ्लैग अंतर्राष्ट्रीय तकनीकी मानक हैं। उन्हें अंग्रेज़ी में रखने से तकनीकी शब्दों का गलत अनुवाद रोका जाता है।
  • क्या इसमें सभी Git कमांड शामिल हैं?इसमें सबसे अधिक उपयोग की जाने वाली कमांड शामिल हैं। पूर्ण संदर्भ के लिए आधिकारिक git दस्तावेज़ देखें।