Git felt scary until I understood one thing: a branch is just a label pointing at a commit. Creating one is cheap, and you can always get back.
The everyday flow I use:
git switch mainandgit pullto start from the latest.git switch -c fix-login-timeoutto make a branch for the change.- Small commits with clear messages: what changed and why.
git push -u origin fix-login-timeout, then open a pull request.- After it's merged, delete the branch and go back to main.
Commands that save me when things go wrong:
git status: always the first thing to run. It tells you where you are.git log --oneline --graph -10: see the shape of recent history.git restore file: throw away changes to one file.git stash: park unfinished work while you switch branches.
And one rule: never rewrite history on a branch other people are using.