1

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.

Rule
  • 629
  • 1
  • 9
  • 19

2 Answers2

1

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

Community
  • 1
  • 1
nwinkler
  • 52,665
  • 21
  • 154
  • 168
  • Thanks for your answer, but I forgot to tell that I cannot commit the file deletions. See my updated question – Rule Jun 24 '15 at 09:12
  • 1
    Maybe take a look at this - it looks similar: http://stackoverflow.com/questions/4589333/git-ignore-locally-deleted-folder – nwinkler Jun 24 '15 at 09:16
  • That was exactly what I was looking for, thx! I've searched SO but didn't find that one. How to proceed with this question, since it's a duplicate? Delete it or? – Rule Jun 24 '15 at 09:18
  • I'll add the link to my answer - then feel free to accept it. – nwinkler Jun 24 '15 at 09:20
1

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

Chris Vogt
  • 1,199
  • 8
  • 11