Even when you work alone, Git is your safety net. A little discipline makes it far more useful.
Branch for every change
Keep main always deployable. Start each feature or fix on its own branch.
git switch -c feat/contact-form
If the experiment fails, delete the branch and nothing is lost.
Commit small and often
One commit should do one thing. Small commits are easy to review, easy to revert and make git bisect possible when a bug appears.
Write messages for future you
A good message says what and why: Add rate limit to login route. Avoid fix stuff. A common convention is a short imperative summary under 70 characters.
Review your own diff
Before committing, run git diff or git add -p. You will catch leftover debug logs and accidental files.
Keep secrets out
Add .env to .gitignore from the first commit. If a secret is ever committed, rotate it immediately; deleting the file later does not remove it from history.
Undo safely
git restore filediscards unstaged changes in a file.git revert <sha>creates a new commit that undoes an old one, safe on shared branches.git refloglists where HEAD has been, so even a bad reset can usually be recovered.
Tags for releases
Tag versions with git tag v1.2.0 so you can always return to a known good state.
Takeaway
Short branches, small commits, clear messages and a habit of reading your diff. It costs seconds and saves hours.
