📖 Git Commands Cheat Sheet

Quick reference guide for commonly used Git commands. Perfect for developers!

âš™ī¸ Setup & Config

git config --global user.name "[name]"

Set your username

git config --global user.email "[email]"

Set your email

git init

Initialize a new repository

git clone [url]

Clone a repository

📝 Basic Commands

git status

Check status of files

git add [file]

Add file to staging

git add .

Add all files to staging

git commit -m "[message]"

Commit with message

đŸŒŋ Branching

git branch

List all branches

git branch [name]

Create new branch

git checkout [branch]

Switch to branch

git merge [branch]

Merge branch

git branch -d [branch]

Delete branch

🌐 Remote Repository

git remote add origin [url]

Add remote repository

git push origin [branch]

Push to remote

git pull

Pull from remote

git fetch

Fetch from remote

â†Šī¸ Undoing Changes

git reset [file]

Unstage file

git checkout -- [file]

Discard changes

git reset --hard

Reset to last commit

git revert [commit]

Revert commit

🔍 Inspection & Comparison

git log

View commit history

git log --oneline

Compact commit history

git diff

Show file differences

git show [commit]

Show commit details

💾 Stashing

git stash

Stash changes

git stash list

List stashes

git stash pop

Apply & remove stash

git stash drop

Delete stash

đŸˇī¸ Tags

git tag

List all tags

git tag [name]

Create tag

git push origin [tag]

Push tag to remote

git tag -d [tag]

Delete tag