How Do I Undo ‘Git Add’ before Commit?

Better Stack Team
Updated on June 21, 2024

To undo a git add command before committing your changes, you can use the git reset command. Here's how you can do it:

Step 1: Check the Status

First, check the status of your files to see which ones you've added:

git status

This will show you which files are currently staged (added) for commit.

Step 2: Undo the git add

To unstage a file that you previously added with git add, you can use:

git reset <file>

Replace <file> with the name of the file you want to unstage. If you want to unstage all files, you can use:

git reset

This will unstage all files that you've added but not yet committed.

Step 3: Check the Status Again

After running git reset, you can check the status again to ensure that the files are no longer staged:

git status

The files that you've just unstaged should now appear as "Changes not staged for commit".


  • git reset will only unstage the changes; it won't discard any modifications you've made to the files.
  • If you want to completely discard the changes in a file that you've added but not yet committed, you can use git checkout -- <file>.
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github