1. Using git add .
Without Reviewing
What goes wrong:
The command stages everything in your working directory—often including unwanted items like .env
files, build artifacts, or temporary logs.
Why it hurts:
You risk committing secrets, oversized binaries, or debug files unintentionally, leading to repository bloat or security exposure. As one medium article highlights, misuse of git add .
frequently results in broken builds or leaked credentials Medium.
Fix:
Always inspect changes with
git status
orgit diff --staged
.Stage files explicitly:
git add path/to/changedFile.js
.
2. Forgetting to Pull Before Pushing
What goes wrong:
You push changes without first pulling updates from the remote. This often causes conflicts or overwritten work if others have pushed in the meantime.
Why it hurts:
Force-pushes or merge conflicts become common, and your changes might inadvertently override teammates’ work. This is cited routinely in Git usage guidelines as a key mistake LinkedIn.
Fix:
Always run
git pull --rebase
before pushing.Use
--force-with-lease
when rewriting history to prevent overwriting others unexpectedly.
3. Committing Large Files or Sensitive Data
What goes wrong:
Developers sometimes commit binaries, logs, or private configuration accidentally. Git tracks everything, so once included, files may persist in history—even after deletion.
Why it hurts:
Huge files slow cloning/pushing, increase repo size indefinitely, and secrets (like API keys) risk public exposure. According to GeeksforGeeks, this mistake is a top cause of inefficient and risky repositories.
Fix:
Use a proper
.gitignore
(e.g.*.log
,node_modules/
,.env
).Leverage Git LFS for binary tracking when needed.
Regularly audit your history for accidental commits (
git log
,git fsck
, or tools like GitGuardian).
4. Bundling Unrelated Changes into a Single Commit
What goes wrong:
You group refactors, formatting changes, and feature updates into one commit.
Why it hurts:
This makes code review difficult, reduces clarity on “why” changes occurred, and makes reversion or blame analysis painful. Researchers report that 75% of teams struggle with tangled commits that mix unrelated changes Medium.
Fix:
Aim for atomic commits: each commit addresses a single concern or task.
Use
git add -p
to selectively stage only relevant hunks.Rebase early in your feature branch to keep history clean before merging.
5. Using git commit --amend
or git rebase
on Shared Branches
What goes wrong:
Amending or rebasing rewrites commit history. If others rely on those commits, merging or pushing can break others' local branches.
Why it hurts:
Changes require force pushes and desynchronize teammates' history—often causing confusion, lost work, or long rebase chains. This is frequently cautioned in Git best-practice literature.
Fix:
Only amend or rebase locally before pushing to avoid history changes visible to others.
For shared branches, prefer
git revert
to undo changes safely without rewriting history.
Additional Tips from the Dev Community
From Reddit's r/git discussions:
“Git runs on simple assumptions, but those assumptions are poorly taught… many users stick to add, commit & merge and never learn deeper features.” LinkedIn
This rings true: most developers learn only the basics and perpetuate common workflow issues.
Summary Table of Git Mistakes & Fixes
|
Final Takeaway
Git is powerful—and forgives few mistakes. But adopting disciplined workflows—staging thoughtfully, pulling & rebasing often, keeping commits clean, and avoiding history rewrites on shared branches—transforms Git from a hazard into a powerful collaboration tool.
NEVER MISS A THING!
Subscribe and get freshly baked articles. Join the community!
Join the newsletter to receive the latest updates in your inbox.