Reputation: 1344
I am using git remove git rm
. I made the simple/stupid mistake of manually deleting a folder with all the files in it BEFORE I used git rm
.
Now I have >15 files that I want to delete from my repo but NOT type out.
Is there a way to do this?
git status
deleted: Literature/abc.md
deleted: Literature/acdf.pdf
deleted: Literature/dsfsdf.pdf
deleted: Literature/dfgdfs.pdf
deleted: Literature/sgadfgaa.md
deleted: Literature/sdsds.pdf
deleted: Literature/sddvasds.rmd
deleted: Literature/ddsds.md
deleted: Literature/fsdfsdsd.png
Upvotes: 3
Views: 99
Reputation: 4591
If you have no other changes currently, and you are sure you need to revert back to the last committed state,
you can use , git reset --hard
which moves the HEAD to last committed hash and discarding all your local changes after that commit
Or, safer way is to do a git reset {path to your deleted folder}
first, to make the files unstaged for next commit, and then doing git checkout -- {path to your deleted folder}
as suggested by @RomainValeri
Upvotes: 1
Reputation: 1
You can use the command
git rm -r --cached
For more details follow the link Bit Bucket Documentation
Upvotes: 0
Reputation: 21908
Yes they're deleted from your worktree, but these files were saved in last revision*, so you just have to restore these files as they were at last commit :
git checkout -- full/path/to/Literature/
then rm
them as you intended in the first place.
* (unless these are new added files but you didn't say so)
Upvotes: 1