How do I undo 'git add'?

danyson

Danyson

Posted on January 29, 2022

How do I undo 'git add'?

Lets say we either did a git add <file-name> to stage a specific modified file or git add . to stage all the modified files.

We may consider git reset but we must do git reset only if we are trying to unstage "a change" in the file.

When we need to just unstage the file.

Good practice is,

if we done a git add <file-name>

Then the solution is git rm --cached

if we done a git add .

Then the solution is git rm -r --cached, as the git add . is recursive, we need to bring in the flag -r

Support Us: Buy Me a Cookie 🍪

💖 💪 🙅 🚩
danyson
Danyson

Posted on January 29, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

How do I undo 'git add'?
beginners How do I undo 'git add'?

January 29, 2022