Comment puis-je défaire > #39;git addΖ#39; before commit

Mots clés : gitundogit-revertgit-addgit

meilleur 5 Réponses Comment puis-je défaire > #39;git addΖ#39; before commit

vote vote

95

git reset <file> 
git reset 
vote vote

81

git rm --cached <added_file_to_undo> 
git reset . 
fatal: Failed to resolve 'HEAD' as a valid ref. 
... # Changes to be committed: #   (use "git rm --cached <file>..." to unstage) ... 
git rm --cached . 
git rm -r --cached . 
git add -n . 
vote vote

77

git status 
use "git reset HEAD <file>..." to unstage 
(use "git rm --cached <file>..." to unstage) 
vote vote

70

git stage 
git reset HEAD -- 
git config --global alias.unadd 'reset HEAD --' git config --global alias.unstage 'reset HEAD --' 
git add file1 git stage file2 git unadd file2 git unstage file1 
git a # For staging git u # For unstaging 
vote vote

59

git gc --prune=now 
$ git init $ echo "version 1" > file.txt $ git add file.txt   # First add of file.txt $ git commit -m 'first commit' $ echo "version 2" > file.txt $ git add  file.txt   # Stage (don't commit) "version 2" of file.txt $ git diff --cached file.txt -version 1 +version 2 $ echo "version 3" > file.txt $ git diff  file.txt -version 2 +version 3 $ git add  file.txt    # Oops we didn't mean this $ git reset HEAD file.txt  # Undo? $ git diff --cached file.txt  # No dif, of course. stage == HEAD $ git diff file.txt   # We have irrevocably lost "version 2" -version 1 +version 3 

Questions similaires