How to ignore file deletions

88 Views Asked by At

Context: For my Android project I have a lot of resources, which slow down my build. I've deleted those files from my filesystem to speed up the build process. But of course GIT sees those changes, and fills up my Sourcetree GIT client making it hard for me to see the actual code changes I make.

I was thinking a solution could be adding these resource files to .gitignore. So I've created a .gitignore file in the res/ folder and committed it. But when I deleted the resource files, GIT still saw them as changes. I think this is because the files are already under GIT control. UPDATE: The file deletions may not be committed, because that will delete the resource files from de development branch when I merge my feature branch.

2

There are 2 best solutions below

4
On BEST ANSWER

If your files had already been part of the Git repo, you will first need to commit the deletions, then add them to .gitignore.

  • git add ... - add all of the deleted files
  • git commit ... - commit the deletions
  • Add the deleted files to .gitignore

Once you've done that, they shouldn't show up anymore as unstaged changes.

If you're only concerned about ignoring the files locally without committing the deletions, please take a look at this question, it's about a similar problem: Git ignore locally deleted folder

0
On

If you have deleted the files from the filesystem, say using rm, you will need to use git add [files] to stage the files for deletion on the next commit.

Or you can use git rm to do this in one step.

See: http://git-scm.com/docs/git-rm