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
Vipin Verma
  • 5,330
  • 11
  • 50
  • 92

1 Answers1

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • No, there is only one gitignore file – Vipin Verma Feb 11 '18 at 05:28
  • @vipin8169 OK, so what is the issue? What file is not ignored that should be ignored? – VonC Feb 11 '18 at 06:08
  • All the lib folders – Vipin Verma Feb 11 '18 at 06: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 Feb 11 '18 at 06: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 – Vipin Verma Feb 11 '18 at 06:10
  • For example `\Pedastals\Library\*` should have been ignored which is not the case – Vipin Verma Feb 11 '18 at 06:11
  • I am using the same gitignore in an another project with similar structure, and it is working fine there. I wonder what is happening in this case, I have tried doing whatever I can with no luck – Vipin Verma Feb 11 '18 at 06:12
  • Can you try, for testing, to modify your .gitignore with library/ and Library/ instead of the current [Ll]ibrary/? – VonC Feb 11 '18 at 06:13
  • `git rm -r --cahed` didn't work, but `git ls-files --ignored --exclude-standard -z | xargs -0 git rm --cached` worked. seems like it is fixed by using this. https://stackoverflow.com/a/23839198/1629932 – Vipin Verma Feb 11 '18 at 06:28
  • @vipin8169 Good point. I have included your comment in the answer for more visibility. – VonC Feb 11 '18 at 06:31