How to UNDO ‘git add’ before commit


Sometimes we might add files in the git to be committed which we actually don’t want to. In such a case before committing the changes we would want to undo the add or remove the file(s) from the list which we don’t want. Here is how we do it:

git reset <file>

this particular line removes the one file mentioned from the about to be committed list. However, if you want to remove all the files from the list, simply hit

git reset

without any file name specified. When there are a lot of files, instead of resetting files one by one, it might be efficient to remove all the files from the list and start over.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: