I have added two new files to my commit, and deleted them after commiting to my local repo , how can delete those files from the same commit.
Asked
Active
Viewed 64 times
2 Answers
2
I'm assuming you did the following:
//Created files A.txt and B.txt
git add A.txt
git add B.txt
git commit -m "Commit message"
Now you want that the previous commit didn't have the two files A.txt and B.txt, so you can do:
git rm A.txt
git rm B.txt
git commit --amend
But remember, if you PUSHED that commit, DON'T AMEND, instead, create a new commit that deletes the two files.

Mark Longair
- 446,582
- 72
- 411
- 327

Gustavo Muenz
- 9,278
- 7
- 40
- 42
-
At least unless you aren't sure that nobody has pulled your changes yet. – ThiefMaster Mar 25 '11 at 13:53
1
git reset --soft HEAD^
This will undo your last commit and put your repo in the state right before you did the last commit. From here you can unstage and undo add/delete of files etc.

rtn
- 127,556
- 20
- 111
- 121