Take a file out of the staging area
Lesson 7 of 24 · Git.Micro
Staged something by mistake? You can take it out of the staging area without losing anything: the file stays in your folder exactly as it is.
git restore --staged file unstages a file; older guides use git reset file.
Unstaging doesn't touch your copy of the file: only the next commit changes.
Passwords and keys must never be committed: once in the history, they're hard to remove.
What happens to secret.env in your folder after git restore --staged secret.env?
Nothing: it stays as it is, just not staged
Someone ran git add . and staged secret.env, which holds a password. Unstage it and commit the other files with the message Add login page.
Do it in the browser: a real Git tool, a short mission and instant feedback. No install.
Start this lesson — free