Git & GitHub Cheat Sheet
Md. Aminul Islam•
Post Date:02 Jan 2026 - 06:41 AM
This guide includes the most important Git & GitHub commands, explained in table format, so you can quickly understand and use them in real projects.
Git Basics Commands
Command | Example | What it does | When to use |
|---|---|---|---|
git init | git init | Create a new Git repository | Start tracking a new project |
git clone | git clone url | Download repo from GitHub | Work on existing project |
git status | git status | Show file changes status | Check before commit |
git add | git add . | Add files to staging area | Prepare files for commit |
git commit | git commit -m "msg" | Save changes permanently | Save version history |
git log | git log --oneline | Show commit history | See previous changes |
Git Add & Commit Flow (Most Important)
Step | Command | Explanation |
|---|---|---|
1 | Edit files | Make changes |
2 | git status | Check changed files |
3 | git add . | Add changes to staging |
4 | git commit -m "message" | Save changes |
5 | git push | Upload to GitHub |
Branch Commands
Command | Example | Explanation | Use case |
|---|---|---|---|
git branch | git branch | Show all branches | Check branches |
git branch name | git branch dev | Create new branch | New feature |
git switch name | git switch dev | Switch branch | Work on branch |
git switch -c name | git switch -c login | Create + switch branch | Faster workflow |
git merge | git merge dev | Merge branch | Combine changes |
git branch -d | git branch -d dev | Delete branch | Clean project |
GitHub Remote Commands
Command | Example | Explanation |
|---|---|---|
git remote add | git remote add origin url | Connect local to GitHub |
git push | git push origin main | Upload code |
git pull | git pull origin main | Download latest code |
git fetch | git fetch | Get remote info |
Undo / Fix Commands (Very Useful)
Command | Example | Explanation |
|---|---|---|
git reset --soft | git reset --soft HEAD~1 | Undo commit keep changes |
git reset --hard | git reset --hard HEAD~1 | Delete commit + changes |
git restore | git restore file.txt | Undo file changes |
git commit --amend | git commit --amend -m "new" | Change last commit |
Stash Commands (Temporary Save)
Command | Example | Explanation |
|---|---|---|
git stash | git stash | Save work temporarily |
git stash pop | git stash pop | Restore work |
git stash list | git stash list | Show stash list |
Git Diff Commands
Command | Example | Explanation |
|---|---|---|
git diff | git diff | Show changes |
git diff --staged | git diff --staged | Show staged changes |
git diff branch1..branch2 | git diff main..dev | Compare branches |
.gitignore Example Table
File | Why ignore |
|---|---|
node_modules | Large folder |
.env | Secret keys |
dist | Build files |
.next | Next.js build |
.DS_Store | macOS file |
Full GitHub Workflow Table
Step | Action | Command |
|---|---|---|
1 | Clone repo | git clone url |
2 | Create branch | git switch -c feature |
3 | Edit code | — |
4 | Add changes | git add . |
5 | Commit | git commit -m "feat: add login" |
6 | Push | git push origin feature |
7 | Create Pull Request | GitHub website |
8 | Merge | GitHub |
Git File Status Meaning
Status | Meaning |
|---|---|
Untracked | New file |
Modified | File changed |
Staged | Ready to commit |
Committed | Saved in Git |
Git vs GitHub Comparison Table
Git | GitHub |
|---|---|
Local tool | Online platform |
Version control | Code hosting |
Works offline | Needs internet |
Tracks changes | Collaboration |
Most Used Commands Quick Table (Daily Use)
Command | Use |
|---|---|
git status | Check changes |
git add . | Add files |
git commit -m | Save changes |
git push | Upload |
git pull | Download |
git switch -c branch | New branch |
Example Real Project Workflow
Pro Tips
Tip | Why |
|---|---|
Use branches always | Safe workflow |
Commit often | Easy rollback |
Write clear messages | Team friendly |
Pull before push | Avoid conflict |


