To undo git add before git commit, do this

git reset <file>

In addition to afore-mentioned example, we can undo staging all files, without any file name. This is useful when there are too many files to be listed one by one in a reasonable amount of time.

git reset
Last modified: January 15, 2018

Author