Put it in git before you let it touch anything
This is the single most important habit. Git is your undo button, and without it you have none. Commit before every sizeable request, so "throw all that away" is one command instead of an afternoon.
$ git init $ git add -A && git commit -m "empty project"
Once you're working, commit whenever a change is good. If a change is bad, git restore . and try the request again with better wording — that is usually faster than arguing it back to correctness.