git – How to commit deleted files from local project?


I have a relatively common problem, but it slows me down a lot on the project, so let's go. Suppose I have a project with the example directories: css , dist , src , js , fonts , and some files in the root like index.html , , config.rd and any other files anyway.

Now let's suppose that in my "src / img" directory I have several images that have already been added, committed all of this locally, no need to throw it to the repository.

Now for some unimportant reason I changed all the files in my "src / img" directory and when I use git status command it returns me a list of new files and deleted files , then I run git add . command git add . adding all the new files to the stage right of what i want to do i git commit -m "Atualizada as imagens do projeto" the changes git commit -m "Atualizada as imagens do projeto" , done "perfect".

But if I run git status again, git status returns the list with ALL those files that no longer exist, and I want them to be deleted from my project committed to git dependencies, but suppose there are more than 200 and all of them have different names and different extensions and are in the same path as my new images, I can't just run git rm src/img/*.jpg or git rm src/img/*.png because my new images will be deleted together.

How can I make it so that I can delete all the old files, regardless of the extension, that are in my committed project there in the git dependencies, but that no longer exist in my local project, with a command just so I don't have to run git rm src/img/exemplo01.png , git rm src/img/exemplo02.png …?


I use $ git add --all , equivalent to $ git add -A .

The difference from $ git add . is that --all also updates the removed files. The add . does not take any action with removed files.

Scroll to Top