DEV Community

Gurmeet Singh
Gurmeet Singh

Posted on

Undo git add command

For adding any files for the commit we add them using git add . for adding all modified files or git add ${fileName} for adding one file at a time.

In some situations, you might want to undo this git add command. You can use the following command to do so

git reset
Enter fullscreen mode Exit fullscreen mode

This command can be used to unstage all files that were staged for the commit.

Whereas if you want to unstage only one particular file you can use the following command

git restore --staged ${fileName}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)