Skip to content

Latest commit

 

History

History
164 lines (114 loc) · 1.8 KB

File metadata and controls

164 lines (114 loc) · 1.8 KB

🔹 Initialize & First Push (Local → GitHub)

git init
git branch -M main
git remote add origin https://github.com/<username>/<repo-name>.git
git add .
git commit -m "Initial commit"
git push -u origin main

🔹 Add Files

git add <file-name>
git add <file1> <file2>
git add .
git add -A

🔹 Commit

git commit -m "message"
git commit -am "message"

🔹 Push (Local → GitHub)

git push
git push origin main

🔹 Pull (GitHub → Local)

git pull
git pull origin main

🔹 Sync Local with Remote (Safe)

git fetch origin
git merge origin/main

🔹 Clone Repo (GitHub → Local)

git clone https://github.com/<username>/<repo-name>.git

🔹 Check Status & History

git status
git log
git log --oneline
git branch

🔹 Branch Commands

git branch <branch-name>
git checkout <branch-name>
git checkout -b <branch-name>
git merge <branch-name>
git branch -d <branch-name>

🔹 Remote Commands

git remote -v
git remote remove origin
git remote set-url origin <new-url>

🔹 Undo / Fix

git restore <file>
git reset <file>
git reset --soft HEAD~1
git reset --hard HEAD~1

🔹 Stash

git stash
git stash pop
git stash list

🔹 Tags

git tag v1.0.0
git push origin v1.0.0

🔹 Force / Rebase (Advanced)

git push --force
git pull --rebase

🔹 Clean

git clean -fd

🔹 Configure (Once)

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

If you want:

  • Cheat-sheet image
  • Beginner-safe subset
  • Professional Git workflow (PR-based)

say the word.