How to remove files from the staging area?
git reset file_name
To remove files from the staging area use git reset file_name
. The command removes any file specified as a parameter from the staging area.
git status
On branch main
Changes to be committed:
(use "git restore --staged..." to unstage)
modified: README.md
git reset README.md
Unstaged changes after reset:
M README.md
git status
On branch main
Changes not staged for commit:
(use "git add..." to update what will be committed)
(use "git restore..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
See git reset to learn more about it.