Ran git add -A in the wrong directory? Undo it
Not committed yet
git restore --staged . # or: git reset
Nothing left your machine. Check git status is clean of things you didn't mean.
Committed, not pushed
git reset --soft HEAD~1
git restore --staged .
Accidentally ran git init in your home folder
If git status works in ~, there's a stray repo there. Check with ls -a ~ | grep .git and remove only ~/.git once you're sure it isn't a dotfiles repo you use.
Already pushed
Treat every secret in those files as leaked: rotate first, then rewrite history. See the .env clean-up guide.
Never again
KatchPath refuses blanket adds from a subfolder or from $HOME, and checks what a blanket add would stage before it runs:
curl -fsSL https://katchpath.com/install.sh | sh
echo 'eval "$(katchpath shell)"' >> ~/.zshrc