Created
April 12, 2012 12:11
-
-
Save dantunes/2366856 to your computer and use it in GitHub Desktop.
Undo a git add - remove files staged for a git commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Unstage a single file from the "about to be commited" | |
git reset filename.txt | |
#Unstage a "git add ." | |
git reset |
6 year ahead, use git checkout </path/filename>
You lose the changes though. I just did! To just unstage them (and keep the changes made), git reset HEAD -- works.
You what? The default if you don't specify anything is a --mixed reset so it's impossible to follow the above snippet and LOSE your changes, since it doesn't use --hard. You made me panic and look through my command line multiple times to check if I lost anything (which I didn't).
--soft: uncommit changes, changes are left staged (index).
--mixed (default): uncommit + unstage changes, changes are left in working tree.
--hard: uncommit + unstage + delete changes, nothing left.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You lose the changes though. I just did! To just unstage them (and keep the changes made), git reset HEAD -- works.