0

I'm doing a Java project using Eclipse with the in build git-functionality. I have an Images folder in the same directory as the .gitignore file. I want to ignore all files in Images except Destroyed-icon.png Layer_dot.png Not-enough-repair-packs-icon.png.
According to Is there a way to tell git to only include certain files instead of ignoring certain files? I should be able to use the following in my .gitignore file, but is doesn't work. The whole Images directory is ignored.

Images
!Images/Destroyed-icon.png
!Images/Layer_dot.png
!Images/Not-enough-repair-packs-icon.png

I already tried adding/removing all / before and after Images, restarting eclipse, closing and reopening the project but none of that worked.
There is nothing to Pull as well, my local repository is up to date.

Xoriun
  • 45
  • 6
  • 1
    Does this answer your question? [.gitignore exclude folder but include specific subfolder](https://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – Kraigolas May 26 '21 at 21:51
  • 1
    In the accepted answer of the above link, they make a note which might answer *exactly* why this doesn't work for you. – Kraigolas May 26 '21 at 21:52
  • 1
    @Kraigolas yes, that's exactly what I needed, thx – Xoriun May 27 '21 at 16:23

1 Answers1

0

The simplest way to deal with this is to ignore Images, and just git add -f the files you want to track. After they have been added, git will keep an eye on them regardless of what .gitignore says about them.

eftshift0
  • 26,375
  • 3
  • 36
  • 60