
Initialize & basic workflow:
git init git add . git commit -m "Initial commit" git push origin main
.gitignore for Python projects:
venv/ __pycache__/ *.pyc .env *.egg-info/ dist/ build/ .pytest_cache/ .mypy_cache/
Branching workflow:
git checkout -b feature/add-login # create & switch git add . git commit -m "Add login feature" git checkout main git merge feature/add-login git branch -d feature/add-login # delete branch
Undoing mistakes:
git diff # see uncommitted changes git checkout -- file.py # discard file changes git reset HEAD~1 # undo last commit (keep changes) git revert HEAD # undo last commit (new commit)
Commit message convention: Start with a verb: "Add login feature", "Fix null pointer bug", "Update README". Keep under 50 chars for the subject line.
Reference:
TaskLoco™ — The Sticky Note GOAT