How can I undo `git add` before commit?
git add feature.txt
I have not run git commit yet. How can I undo/reverse/revert this so that this change will not go in the commit?
Please pay attention to update your answer.
Update Your Answer care fully. After saving you can not recover your old answer
If you accidentally added files using git add but haven’t committed yet, you can safely undo it using the git reset command.
To unstage a specific file (e.g., feature.txt):
git reset feature.txt
This removes the file from the staging area but keeps your local changes intact. your edits in feature.txt will still be there.
To unstage all files you added:
git reset
This unstages everything, returning all files to the ‘modified but not staged’ state.
Tip: Run git status afterward to confirm that the files are no longer staged for commit.
Please pay attention to update your answer.
Update Your Answer care fully. After saving you can not recover your old answer
you can unstage a Single File
If you only added one file, for example feature.txt, run:
git reset feature.txt
This will remove the file from the staging area, but keep your changes in the working directory.
You can still edit or re-add it later.
Please pay attention to update your answer.
Update Your Answer care fully. After saving you can not recover your old answer
you can Unstage All Files
If you want to undo git add for all staged files, use:
git reset
This unstages everything that was added, keeping all your local modifications intact.
