DEV Community

Kyle Y. Parsotan
Kyle Y. Parsotan

Posted on

Here are the most common Git mistakes beginners make and exactly how to fix them. Think of this as your “Git emergency guide.”

🚨 Committed to the wrong branch

❌ Mistake

You meant to work on feature-login, but accidentally committed to main.

🔧 Fix

Check where you are:

git branch
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Move commit to a new branch:

git branch feature-login
git reset --soft HEAD~1
git checkout feature-login
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Now your commit is safely on the correct branch.


🚨 Forgot to add files before committing

❌ Mistake

You committed but changes are missing.

🔧 Fix

Add missing files and amend commit:

git add .
git commit --amend
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Wrong commit message

❌ Mistake

git commit -m "fix"
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🔧 Fix

git commit --amend -m "Fix login validation error"
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

If already pushed:

git push --force
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Pushed to GitHub accidentally

❌ Mistake

You pushed messy or wrong commits.

🔧 Fix (safe undo)

Reset locally:

git reset --soft HEAD~1
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Then force update remote:

git push --force
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

⚠️ Only do this if you're sure nobody else pulled the code.


🚨 Merge conflict confusion

❌ Mistake

Git shows:

CONFLICT (content): Merge conflict in file.js
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🔧 Fix

  1. Open the file
  2. Look for:
<<<<<<< HEAD
your code
=======
incoming code
>>>>>>> branch
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026
  1. Manually choose correct code
  2. Then:
git add .
git commit
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Accidentally deleted files

❌ Mistake

You removed a file and need it back.

🔧 Fix

Restore file:

git checkout -- filename
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Or newer Git:

git restore filename
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Lost commits (panic moment 😱)

❌ Mistake

You reset or switched branches and “lost” work.

🔧 Fix

Recover using reflog:

git reflog
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Find commit ID, then:

git checkout <commit-id>
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Or restore branch:

git reset --hard <commit-id>
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Wrong branch pushed to GitHub

❌ Mistake

You pushed feature work to main.

🔧 Fix

Create correct branch from commit:

git checkout -b feature-branch
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Then reset main:

git checkout main
git reset --hard origin/main
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Forgot to pull before pushing

❌ Mistake

rejected - non-fast-forward
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🔧 Fix

Pull first:

git pull origin main
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Then push again:

git push
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

If conflicts happen, fix them then commit.


🚨 Messy commit history

❌ Mistake

Too many “fix fix fix” commits.

🔧 Fix (clean history)

Use interactive rebase:

git rebase -i HEAD~3
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Then:

  • squash commits
  • edit messages
  • clean history

🚨 11. Stuck in Vim editor (VERY common 😭)

❌ Mistake

Git opens strange screen and you can’t exit.

🔧 Fix

Exit Vim:

ESC → :wq → Enter   (save & exit)
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Or:

ESC → :q! → Enter   (exit without saving)
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🚨 Accidentally staged wrong files

❌ Mistake

You added too many files:

git add .
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🔧 Fix

Unstage everything:

git reset
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

Or specific file:

git restore --staged filename
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

🧠 Quick “panic commands” cheat sheet

If something goes wrong, try:

git status
git log --oneline
git reflog
git reset --hard HEAD
git restore .
⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026 ⚽ Live Match: kyl/here are the most common git mistakes beginners make and exactly how to fix them think of this as fkb - Info Live Streaming 2026

💡 Final Advice

Most Git mistakes are not permanent.

Rule of thumb:

Git almost always has a way back if you use reflog or commits properly.

Top comments (0)