Skip to content

Instantly share code, notes, and snippets.

@dantunes
Created April 12, 2012 12:11
Show Gist options
  • Save dantunes/2366856 to your computer and use it in GitHub Desktop.
Save dantunes/2366856 to your computer and use it in GitHub Desktop.
Undo a git add - remove files staged for a git commit
#Unstage a single file from the "about to be commited"
git reset filename.txt
#Unstage a "git add ."
git reset
@LiamDobbelaere
Copy link

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