DEV Community

Gurmeet Singh
Gurmeet Singh

Posted on

3 2

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay