The 10 Git Mistakes That Waste Developers' Time Every Week
Learn to avoid ten common Git mistakes that slow down developers, with commands and fixes you can apply immediately.
Before you start
You are in the middle of a feature branch. You run git pull and suddenly you are staring at merge conflicts in files you never touched. Or you accidentally commit to main and spend an hour trying to undo it. Or you force push over a teammate's work and now everyone is angry. These are not rare events. They are recurring patterns that eat hours every week.
This article walks through ten Git mistakes that waste developer time, with concrete commands to fix each one. You can run these commands today. I have organized them from the most common to the sneakiest. By the end, you will have a safer Git workflow and a checklist to prevent these issues from happening again.
- You have Git 2.30 or newer installed. Check with git --version.
- You have a local repository to practice on. Use a throwaway repo if you need to test.
- You are comfortable with the command line and basic Git concepts like commit, branch, and remote.
Mistake 1: Committing directly to main
Committing straight to main is the fastest way to create a mess. You skip code review, you break the build, and you make it hard to roll back individual changes. Even in a solo project, main should be your stable branch.
The fix is simple: create a feature branch for every change, no matter how small. Use a consistent naming convention like feature/description or bugfix/issue-number.
# Instead of committing on main, create a branch first
git checkout -b feature/add-login
# ... make changes ...
git add .
git commit -m "Add login form"
git push -u origin feature/add-login- Make it a habit: never commit directly to main. Even a one-line typo fix gets a branch.
- Use branch protection on your remote to enforce this. On GitHub, require pull requests before merging to main.
Mistake 2: Not pulling before you push
You finish your work, run git push, and get a non-fast-forward error. Someone else pushed to the same branch while you were working. Now you have to integrate their changes, which often leads to merge conflicts and extra commits.
The habit to build is: pull with rebase before you push. This replays your commits on top of the latest remote changes, keeping the history linear and minimizing conflicts.
# Before pushing, pull with rebase
git pull --rebase
# If conflicts arise, resolve them, then continue the rebase
git add <resolved-files>
git rebase --continue
# Then push
git push- If you have local commits that are not yet pushed, always pull --rebase before pushing.
- If you are working on a shared branch and you have already pushed commits, avoid rebasing unless you coordinate with the team.
Mistake 3: Committing secrets and large files
You accidentally commit an .env file with API keys or a 200 MB database dump. Now the secret is in the history, and the repo is bloated. Even if you delete the file, it stays in the history forever.
The fix is to use a .gitignore file from the start. And if you do commit a secret, you must rotate it immediately, not just remove the file.
# Example .gitignore
.env
*.log
node_modules/
dist/
build/
*.sql.gz
.DS_Store- Add .gitignore before your first commit. You can generate one with gitignore.io.
- If you commit a secret, consider it compromised. Rotate it and remove it from history with tools like git filter-repo.
Mistake 4: Unclear commit messages
Commit messages like 'fix stuff' or 'update' make it impossible to understand what changed and why. When you need to revert a change or review history, you waste time digging through diffs.
Follow a convention like Conventional Commits. It makes the history readable and enables automated changelogs.
# Good commit message
git commit -m "fix(auth): handle token expiry on login"
# Bad commit message
git commit -m "fix stuff"- Use the format: type(scope): subject. Types include feat, fix, docs, style, refactor, test, chore.
- Keep the subject under 50 characters. Add a body if you need to explain the why.
Mistake 5: Using force push recklessly
Force push rewrites history and can destroy your teammates' work. It is the number one cause of lost commits in collaborative projects.
Use --force-with-lease instead of --force. It checks that the remote branch is in the state you expect before overwriting, so you do not clobber someone else's commits.
# Safe force push
git push --force-with-lease origin feature/my-branch
# Dangerous force push
git push --force origin feature/my-branch- Never force push to shared branches like main or develop.
- If you need to rewrite history on a shared branch, coordinate with the team and use a temporary branch.
Mistake 6: Not using branches for experiments
You want to try a new approach, so you start editing files on your current branch. Halfway through, you realize it does not work. Now you have to manually revert changes or reset your branch, losing work you might want later.
The fix is to create a throwaway branch for experiments. If it works, merge it. If not, delete it and move on.
# Create an experiment branch
git checkout -b experiment/new-approach
# ... try things ...
# If it fails, switch back and delete the branch
git checkout main
git branch -D experiment/new-approach- Use branches for anything that might not work out. It costs nothing.
- Name experiment branches clearly, like experiment/rate-limiter or wip/new-cache.
Mistake 7: Ignoring merge conflicts until the last minute
You work on a feature for a week without syncing with main. When you finally try to merge, you have dozens of conflicts that take hours to resolve.
The habit to build is to integrate main into your feature branch regularly. Do it daily or every few days. This surfaces conflicts early when they are small and fresh in your mind.
# Regularly pull main into your feature branch
git checkout main
git pull
git checkout feature/my-feature
git merge main
# Resolve conflicts as they appear- If you are on a long-lived branch, merge or rebase main into it at least every day.
- Use git mergetool to help resolve conflicts interactively.
Mistake 8: Relying on git stash for everything
Stash is handy for saving uncommitted work, but it can be a black hole. You stash changes, forget about them, and later you cannot find them. Or you pop the wrong stash and get conflicts.
Use stash only for quick context switches. For longer-term work, commit to a branch. That way your work is visible and recoverable.
# Instead of stashing for hours, commit to a branch
git checkout -b wip/my-changes
git add .
git commit -m "WIP: partial changes"
# When you return, you can continue or rebase- List stashes with git stash list. If you have more than a few, it is time to clean up.
- Use git stash pop instead of apply to avoid leaving duplicates.
- Consider using git worktree to have multiple branches checked out at once, avoiding stash altogether.
Mistake 9: Not reviewing your own diff before committing
You commit without reviewing the diff, and later you find that you accidentally included a debug console.log or a file you did not mean to touch. This leads to extra commits and noise.
Always review the diff before staging. Use git diff and git diff --cached to see what will be committed.
# Review unstaged changes
git diff
# Review staged changes
git diff --cached
# Stage specific files instead of everything
git add src/app.ts
git add tests/app.test.ts- Stage files explicitly. Avoid git add . unless you know exactly what is in the working directory.
- Use git status before committing to see what is staged and what is not.
Mistake 10: Not using Git aliases for common commands
You type the same long Git commands over and over. Each command takes a few seconds, but they add up. Aliases save you time and reduce typos.
Set up aliases for your most frequent commands. Here is a starter set.
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all --decorate"
git config --global alias.unstage "reset HEAD --"
git config --global alias.last "log -1 HEAD"- You can also add aliases for complex commands like git lg to see a graph of your history.
- Share your aliases with your team so everyone works faster.
What I would do: recommended Git setup
Here is a copy-paste starter setup that incorporates all the fixes above. It sets up a safer default configuration and a few aliases that will save you hours.
Run these commands in your terminal to configure Git globally.
# Set your identity (if not done)
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
# Pull with rebase by default
git config --global pull.rebase true
# Use force-with-lease as default
git config --global push.default current
# Enable color output
git config --global color.ui auto
# Add useful aliases
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all --decorate"
git config --global alias.unstage "reset HEAD --"- Set pull.rebase true so git pull behaves like git pull --rebase by default.
- Use push.default current so git push pushes the current branch to a branch with the same name.
- Add more aliases as you find yourself typing long commands.
Verify it worked
After applying the recommended setup, verify that your configuration is correct and that the aliases work.
Run the following commands to check.
# Check your Git configuration
git config --global --list
# Test an alias
git lg
# Test pull rebase behavior (in a repo with a remote)
git pull- The git config --global --list should show your user.name, user.email, pull.rebase, push.default, and aliases.
- git lg should show a colorful graph of your commit history.
- git pull should now use rebase by default, so the output will say Rebase or Updating instead of Merge.
Troubleshooting
If something does not work as expected, here are a few common issues and how to fix them.
- If git pull --rebase fails because you have unstaged changes, commit or stash them first.
- If you accidentally force pushed and lost commits, check the reflog with git reflog and reset to the commit you need.
- If your .gitignore is not working, check that the file is in the root of the repo and that you have not already tracked the file. Use git rm --cached <file> to untrack it.
FAQ
Here are answers to common questions about Git mistakes.
- Q: How do I undo the last commit without losing changes? A: Use git reset --soft HEAD~1 to undo the commit but keep your changes staged.
- Q: What is the difference between git merge and git rebase? A: Merge creates a merge commit and preserves history. Rebase rewrites history to create a linear sequence. Use rebase for local branches and merge for shared branches.
- Q: How do I recover a deleted branch? A: Use git reflog to find the commit hash, then create a new branch with git branch <branch-name> <hash>.
- Q: How do I remove a file from Git history? A: Use git filter-repo or the BFG Repo-Cleaner. This rewrites history, so coordinate with your team.
- Q: How do I set up branch protection on GitHub? A: Go to repository settings, select Branches, add a rule for main, and require pull request reviews before merging.
Next action
Pick one mistake from this list and fix it today. The quickest win is to set up the recommended Git aliases and pull.rebase. Run the configuration commands now, and you will save time on every future pull and push.
If you want to check your current Git configuration, run git config --global --list and look for potential problems like missing user.name or unsafe force push habits.
Key takeaways
- Apply one concrete change from this post before collecting more reading.
- Prefer browser-side tools when the work involves secrets, tokens, or PII.
- Document the why next to the how so the next reviewer inherits context.
FAQ
- Who is this guide on git for?
- Working developers who need a practical take on the 10 git mistakes that waste developers' time every week — not a marketing overview. Skim the sections, apply one tip, then come back when you hit an edge case.
- Do I need an account to use the related tools?
- No. code.live tools run in your browser with no signup. Nothing you paste is uploaded to a server for the client-side utilities linked from this post.
- How often is this article updated?
- This post was published September 8, 2026. Fundamentals stay stable; check linked tool pages and official docs when version-specific behavior matters.