5

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
turbo
  • 1,233
  • 14
  • 36
  • "seem to be random" - really? Can you extract a minimal example? Without any way to reproduce this, your question isn't answerable. That said, there isn't even a programming question here, so your question is basically off-topic. – Ulrich Eckhardt Feb 23 '16 at 20:25
  • @UlrichEckhardt The "random" part is no longer the case. After re-cloning the repo again, it is now always the same (depicted in the screenshot). About the on-topic-ness, questions about [`software tools commonly used by programmers`](http://stackoverflow.com/help/on-topic) are perfectly fine here. – turbo Feb 23 '16 at 20:35
  • 1
    Are those files in the repo already? `.gitignore` only prevents new files from being added, it doesn't prevent updates from being tracked to files already present. Try `git clone` into a brand new folder and see if the dll files are present – Daenyth Feb 23 '16 at 20:35
  • @Daenyth The files are not present in the actual github repo. – turbo Feb 23 '16 at 20:36
  • If you use `git-bash` and don't use the Github Desktop app, does this still happen with a fresh repository? – Daenyth Feb 23 '16 at 20:37
  • @Daenyth No, strangely git-bash (as well as git in non-windows OS's) works fine. – turbo Feb 23 '16 at 20:38
  • That implies that this is a bug in Github Desktop – Daenyth Feb 23 '16 at 20:39

1 Answers1

1

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.

8forty
  • 545
  • 4
  • 13
  • I deleted both the remote and local repository (after manually downloading the files from github) and re-created a new repo. I also double-checked that no files matching my gitignore we present. This is how I solved it in my case. Thanks for the tips though - it'll be a nice reference for anyone with similar issues. – turbo Mar 01 '16 at 06:43