1

I have the following .gitignore for my unity project parent folder which has multiple unity game folders inside. I have tried using git rm --cached as well but it seems like it is not stopping the tracking of library folder. The folder structure is as follows, where Car Racing, Hat trick etc, are all independent unity game folders. enter image description here

[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*

# Visual Studio 2015 cache directory
/.vs/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb

# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

# Data generated by Visage tracking
*EMOTION*.txt
/*/*-*-*-*-*-*-*.txt
3
  • shouldn't a */ at the beginning solve it? like */[Ll]ibrary/ and so on?
    – derHugo
    Commented Feb 12, 2018 at 16:12
  • I tried it, didn't work. Commented Feb 12, 2018 at 19:37
  • 1
    If you already committed it once before than files stay tracked even if they are added to gitignore.
    – derHugo
    Commented Feb 13, 2018 at 7:58

1 Answer 1

1

Make sure those "independent unity game folders" don't have their own .git subfolder: that would make them nested Git repo within your main parent repo, and your main .gitignore file would be ignored in those sub-repo.

You can also make sure a file is still not ignored with:

git check-ignore -v -- a/path/to/file

That being said, git rm --cached alone is not enough.

As the OP vipin8169 points out in the comments (and this answer), this is better:

 git ls-files --ignored --exclude-standard -z | \
    xargs -0 git rm --cached
 git commit -am "Remove ignored files
10
  • No, there is only one gitignore file Commented Feb 11, 2018 at 5:28
  • @vipin8169 OK, so what is the issue? What file is not ignored that should be ignored?
    – VonC
    Commented Feb 11, 2018 at 6:08
  • All the lib folders Commented Feb 11, 2018 at 6:09
  • @vipin8169 Can you give an example of a full path which should be ignored? What rule in your .gitignore should have ignored that file?
    – VonC
    Commented Feb 11, 2018 at 6:10
  • These files were checked by someone else, and he checked in all the library folders and everything which should have been a part of gitignore. I updated the gitignore to the one i mentioned in question above and also did git rm -r --cached, but still they are getting tracked by git Commented Feb 11, 2018 at 6:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.