How To Undo `git add` Before Commit
Let's say you've accidentally added files to Git that you didn't mean to like this:
git add wrong-file.txt
This is called "staging" the files.
If you haven't comitted with
git commit yet and you want to undo this ("unstage" the files) then you can simply do this:
git reset wrong-file.txt
This will take you back to the point before you added the wrong file to be committed, allowing you to start again.
If you want to unstage all of the changes, not just one file, you can simply do: