7
I accidentally added all the files to the staging area of git with the "git add." , how to remove a file from staging area so it is not commited?
7
I accidentally added all the files to the staging area of git with the "git add." , how to remove a file from staging area so it is not commited?
10
As mentioned in the message of git status
(use "git reset HEAD <file>..." to unstage), the command is:
git reset HEAD <file>...
If you want to remove a file:
git reset HEAD caminho/para/o/arquivo
If you want to clean up the whole staging, go to the repository root directory and use the command:
git reset HEAD *
Browser other questions tagged git
You are not signed in. Login or sign up in order to post.
One way to avoid accidents like this in the future is to add the files incrementally with the command
git add -p
(patch mode). This allows you to add each change individually. (User suggestion @mollusk: Thank you! I preferred to add as a comment rather than include in the reply.)– J. Bruni
About how to avoid accidents, I think
git add -u
is closer to the desired result. Does not add new files and does not ask for confirmation of each modified snippet.– Marcos Banik