How to commit files deleted from the local project?

7

DESCRIPTION:
I have a relatively common problem, but it takes a lot of time on the project, so let's go. Suppose I have a project with the directories examples: css , dist , src , js , fonts , and some files in the root like index.html , readme.md , config.rd and any other files, anyway.

Now suppose that in my src / img directory I have several images that have already been added, commit all this locally even without having to play to the repository.

PROBLEM:
Now for any unimportant reason I've changed all the files in my directory and when I use git status command it returns me a list of the files new and deleted files , then I run the command git add . adding all the new files to the stage of what I want to do I commit the changes git commit -m "Atualizada as imagens do projeto" , ready "perfect".

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

QUESTION:
How can I do so that I can delete all the old files, regardless of the extension, that are in my project comitated there in the dependencies of git, but that no longer exist in my local project, with a command just so I do not have to execute git rm src/img/exemplo01.png , git rm src/img/exemplo02.png ...?

    
asked by anonymous 29.11.2014 / 21:59

2 answers

10

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

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

    
29.11.2014 / 22:22
4

I went through this problem right now, and found in the English OS a solution that worked for me:

git ls-files --deleted -z | xargs -0 git rm

Source: Mark Longair's Answer Delete files from git index when they are already deleted from fs

    
18.12.2014 / 21:56