I made a mistake and called git add -all
, now all files are added. I did not make a commit
and push
. How can I undo my action?
Asked
Active
Viewed 9.4k times
103

ROMANIA_engineer
- 54,432
- 29
- 203
- 199

BendEg
- 20,098
- 17
- 57
- 131
-
4did you try `git reset HEAD` ? – karthikr Jan 18 '15 at 15:02
-
this is not a duplicate since clearly it is stated this is undo git add -all. There are many resources for undoing git add but for -all there are very few. – KansaiRobot Jul 05 '23 at 11:40
2 Answers
121
It has already been answered several times:
You can use
git reset
. This will 'unstage' all the files you've added after your last commit.If you want to unstage only some files, use
git reset -- <file 1> <file 2> <file n>
.Also it's possible to unstage some of the changes in files by using
git reset -p
.
See

Community
- 1
- 1

Simone Carletti
- 173,507
- 49
- 363
- 364
-
5If it was already answered several times, the correct course of action would be to vote to mark as duplicate, and not answer the question. – Madara's Ghost Jan 18 '15 at 15:04
-
@SecondRikudo That's what I did, look at my comment at the top. The reason I posted is to provide more than one answer link. – Simone Carletti Jan 18 '15 at 15:04
-
4Emphasizing the **and not answer the question** part. The idea is that if someone searches Google for this problem, they'd find the canonical with the best answer, and not one of the many duplicates asked. By answering these questions you're giving them more visibility. – Madara's Ghost Jan 18 '15 at 15:05
-
I did this reset and it said it unstaged them but they're still in the index because if I a git status it shows them marked as modified still. How do I COMPLETELY get rid of changes bot added and committed locally? – PositiveGuy Oct 16 '15 at 02:37
-
14
To reset specific files you can use: git reset -- <file_a> <file_b>
or to reset all your changes you can use git reset
.

nitishagar
- 9,038
- 3
- 28
- 40