Skip to main content
DevTools24

Git चीटशीट

Git कमांड संदर्भ।

git config --global user.name "Your Name"
Set your username globally
git config --global user.email "email@example.com"
Set your email globally
git config --list
List all Git configuration
git config --global core.editor "code --wait"
Set VS Code as default editor
git init
Initialize a new Git repository
git clone <url>
Clone a repository
Example: git clone https://github.com/user/repo.git
git status
Show working tree status
git add <file>
Stage a specific file
Example: git add index.js
git add .
Stage all changes
git add -p
Interactively stage changes
git commit -m "message"
Commit staged changes
Example: git commit -m "Add feature"
git commit -am "message"
Stage and commit all tracked files
git commit --amend
Modify the last commit
git commit --amend --no-edit
Amend without changing message
git branch
List local branches
git branch -a
List all branches (local + remote)
git branch <name>
Create a new branch
Example: git branch feature-login
git checkout <branch>
Switch to a branch
git checkout -b <branch>
Create and switch to new branch
Example: git checkout -b feature-login
git switch <branch>
Switch to a branch (newer syntax)
git switch -c <branch>
Create and switch (newer syntax)
git branch -d <branch>
Delete a merged branch
git branch -D <branch>
Force delete a branch
git branch -m <old> <new>
Rename a branch
git merge <branch>
Merge branch into current branch
Example: git merge feature-login
git merge --no-ff <branch>
Merge with merge commit
git merge --abort
Abort a merge in progress
git rebase <branch>
Rebase current branch onto branch
git rebase --abort
Abort a rebase in progress
git rebase --continue
Continue after resolving conflicts
git remote -v
List remote repositories
git remote add origin <url>
Add a remote repository
git push
Push to remote
git push -u origin <branch>
Push and set upstream
git push --force
Force push (use with caution!)
git pull
Fetch and merge from remote
git fetch
Fetch from remote without merging
git fetch --prune
Fetch and remove deleted remote branches
git reset <file>
Unstage a file
git reset --soft HEAD~1
Undo last commit, keep changes staged
git reset --mixed HEAD~1
Undo last commit, keep changes unstaged
git reset --hard HEAD~1
Undo last commit, discard changes
git checkout -- <file>
Discard changes in file
git restore <file>
Discard changes (newer syntax)
git restore --staged <file>
Unstage a file (newer syntax)
git revert <commit>
Create commit that undoes changes
git clean -fd
Remove untracked files and directories
git stash
Stash current changes
git stash save "message"
Stash with a message
git stash list
List all stashes
git stash pop
Apply and remove last stash
git stash apply
Apply last stash without removing
git stash drop
Remove last stash
git stash clear
Remove all stashes
git log
Show commit history
git log --oneline
Show compact commit history
git log --graph
Show history with branch graph
git log -p <file>
Show file history with diffs
git diff
Show unstaged changes
git diff --staged
Show staged changes
git diff <branch1>..<branch2>
Compare two branches
git show <commit>
Show a specific commit
git blame <file>
Show who changed each line
git tag
List all tags
git tag <name>
Create a lightweight tag
Example: git tag v1.0.0
git tag -a <name> -m "message"
Create an annotated tag
git push --tags
Push all tags to remote
git tag -d <name>
Delete a local tag
Quick Tips:
  • • Use git status frequently to see current state
  • • Create feature branches with git checkout -b feature-name
  • • Use git stash to temporarily save work
  • • Always review changes with git diff before committing

Git Version Control - तकनीकी विवरण

Git is the most widely used version control system. Understanding Git commands helps you manage code history, collaborate with teams, and recover from mistakes. Start with basic commands and gradually learn advanced features.

कमांड-लाइन विकल्प

# Essential workflow
git add .
git commit -m "message"
git push origin main

# Undo last commit
git reset --soft HEAD~1

संदर्भ

आधिकारिक स्पेसिफिकेशन देखें