How do I undo 'git add' before commit?

How do I undo ‘git add’ before commit?

Hello Priyanka,

To undo a git add before committing, you can use the following command.

git reset <file>

This command unstages the file, keeping your changes in your working directory.

Hey Prynka

Using git restore (Git version 2.23 and later):

git restore --staged <file>

This command unstages the file, similar to git reset, but using the new git restore command.

Hii Prynka,

Using git rm:

git rm --cached <file>

This command removes the file from the staging area, but keeps it in your working directory.