git restore --staged <pathname>

Unstages the specified file/s

This command is particularly useful when a file has been added to the staging area (via git add) by mistake, and you want to 'unstage' it without losing any changes made to it.

--staged specifies that you would like to only unstage the changes, meaning that the changes will still exist in your working directory but will not be included in the next commit.

Note that git restore is a fairly new command, and on older versions of git, the equivalent command would be git reset HEAD <pathname>.

Specific examples:
git restore --staged README.md
git restore --staged src

Sign in to enable bookmarking, reminders, progress-tracking and more...