7 mistakes that most often break your workflow.
1. Working Without Branches
Problem: everything is committed directly to main, history becomes a mess.
# Bad
git commit -m "fix"
git push origin main
# Good: a branch for each task
git checkout -b feature/add-login
# ... make changes ...
git commit -m "feat: add user login form"
git push origin feature/add-login
# then Pull Request → code review → merge
main should always contain working code.
2. Meaningless Commit Messages
# Bad
git commit -m "fix"
git commit -m "asdfasdf"
git commit -m "done"
# Good — type: what was done
git commit -m "fix: fix email validation error"
git commit -m "feat: add export to PDF button"
git commit -m "refactor: optimize database query"
Types: feat, fix, docs, refactor, test, chore.
3. Secrets in the Repository
# DANGEROUS — don't commit!
SECRET_KEY = "django-insecure-key-123"
API_KEY = "sk_live_51234567890"
# Correct — use environment variables
import os
SECRET_KEY = os.getenv('SECRET_KEY')
API_KEY = os.getenv('API_KEY')
Create a .env file and add it to .gitignore. Commit a .env.example with placeholders for your team.
echo ".env" >> .gitignore
git add .gitignore
git commit -m "chore: add .env to gitignore"
4. Committing Everything Without .gitignore
# Bad: node_modules, .DS_Store, .env end up in the commit
git add .
# .gitignore for a Python/Django project
*.pyc
__pycache__/
.env
.venv/
db.sqlite3
media/
.DS_Store
.vscode/
.pytest_cache/
Always check git status and git diff before committing.
5. Push Without Pull First
# Error: a colleague already pushed, you get "rejected"
git push origin main
# ERROR: Updates were rejected
# Correct
git pull --rebase origin main
git push origin main
6. Force Push to a Shared Branch
# DANGEROUS: rewrites history for everyone
git push --force origin main
# Safe alternative (only if absolutely necessary)
git push --force-with-lease origin main
# Refuses if someone pushed after your last pull
Force push is only acceptable on your own personal feature branches.
7. Huge Commits and Broken Code
Problem: 3 days of work in one "done" commit — impossible to code-review or revert a specific change.
# Good: 1 commit = 1 logical change
git add auth/login.py
git commit -m "feat: add login form"
git add auth/validators.py
git commit -m "feat: email and password validators"
Before committing, make sure the code works: run tests (pytest) and check python manage.py check.
Pre-Push Checklist
- [ ]
git status— checked what I’m adding - [ ]
.envand secrets are not in the commit - [ ] Commit message is meaningful
- [ ]
git pulldone beforegit push - [ ] Working in the correct branch (not
main) - [ ] Tests pass
💬 Comments (0)
No comments yet
Be the first to share your opinion about this article!