Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitignore misses some binary files (DLLs & PEs)

I use the latest version of Github Desktop. My repo consist of a rather large C# solution with many sub-directories and projects. I'd like to ignore all R#-cache files and compiled binaries using the .gitignore file which resides in the root directory of the local repo directory. There are no other gitignore's anywhere in this repo and none in any parent directories. My current gitignore is this:

*.suo
*.user
_ReSharper.*
bin
obj
packages
*.cache
*.pdb
*.dll
*.exe
*.xml

When I made my changes, recompiled and tested everything, I open Github Desktop. It catches almost all files that should be ignored, only some .dlls, .pdbs and .exes are not ignored and always show up as changed:

img

Now, there are way more binary files in this repo. Only the specific ones in the screengrab are missed.

Is this fixable, and/or can the gitignore be altered to catch all files that it should catch?

Here's what I tried:

  • Removed and re-cloned the repository
  • Removed and manually re-created the gitignore
  • Right-click->Ignore by file extension from within the GitHub Desktop client. This does not work, worse, it creates duplicate masks in the gitignore
  • Checked for conflicting gitignore's in directories accessible by Github Desktop
like image 843
turbo Avatar asked Nov 08 '22 20:11

turbo


1 Answers

Maybe you have files that were already being tracked by git before you modified the .gitignore? Those files (at least in git 1.9.1) aren't ignored when added to a .gitignore.

For example, I created a "test" directory at the root file one of my repos and put a file in it:

mkdir test
echo "abc" > test/x.txt

I added, committed and pushed it. Then I edited .gitignore at the root and added this line:

x.txt

I also made an edit to test/x.txt AND added a new file:

echo "123" >> test/x.txt
mkdir test2
echo "xyz" > test2/x.txt

Now when I run "git status" I see:

modified:   .gitignore
modified:   test/x.txt

So test2/x.txt is being properly ignored, but test/x.txt is still being tracked.

To force the file to be ignored, you can delete it, add & commit the deletion together with the .gitignore change, then restore the file.

like image 98
8forty Avatar answered Dec 26 '22 10:12

8forty