Possible Duplicate:
Undo git add before commit
When i was working on my project I accidently added files using the following command
git add file
I haven't yet run
git commit.
How can I undo or remove these newly added files from the commit?
Please help.
To undo git add before a commit, run git reset <file> or git reset to unstage all changes.
The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.
To unstage commits on Git, use the “git reset” command with the “–soft” option and specify the commit hash. Alternatively, if you want to unstage your last commit, you can the “HEAD” notation in order to revert it easily. Using the “–soft” argument, changes are kept in your working directory and index.
git reset
is a literally "undo" of git add
- it removes the changes from staged area.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With