Explore Courses Blog Tutorials Interview Questions
+1 vote
1 view
in DevOps and Agile by (19.7k points)

I made changes to some of my files in my local repo, and then I did git add -A which I think added too many files to the staging area. How can I delete all the files from the staging area?

After I do that, I'll just manually do git add "filename".

1 Answer

+2 votes
by (62.9k points)

If you've already committed a bunch of unwanted files, you can unstage them and tell git to mark them as deleted (without  them being actually deleted) using this command

git rm --cached -r

--cached tells it to remove the paths from staging area and the index without removing the files themselves and -r operates on directories recursively till it has done his work of removing the paths from staging area for all files. You can then git add any files that you want git to keep track of.

Browse Categories