Git not tracking a file from a folder - contents.json from .xcassets

3.8k views Asked by At

I have checked almost all the questions on SO but nothing has worked for me. The issue that I'm unable commit the Contents.json file of .xcassets whatsoever. Whenever I add new images to .xcassets the source control does list the images but not the Contents.json file. I'm using a bitbucket repository and not even SourceTree is showing this file in the uncommitted changes. Even tried adding all the files via terminal.

git add --all

Any guess why this is happening and what could possibly be the solution?

Update: The .gitignore file looks like:

ProjectName.xcworkspace/xcuserdata
ProjectName.xcodeproj/xcuserdata
*.xcscheme
xcschememanagement.plist

And .git/info/exclude looks something like:

.DS_Store
UserInterfaceState.xcuserstate
2

There are 2 answers

8
Arpit Aggarwal On

Probably you have .xcassets/Contents.json in one or more of the three ignore files .gitignore, .git/info/excludes and ~/.gitexclude.

If that is not the case then try executing below command which will ask Git to start tracking the file again:

git update-index --no-assume-unchanged <file>

For your case:

git update-index --no-assume-unchanged .xcassets/Contents.json
3
Azot On

A lot of time has passed, but it seems I know what it is. I encountered the same problem, and every time I added resources, I had to manually do the following steps: git add -f

However, I found out about the command: git status --ignored The command shows all ignored files. After that, I made the git add -f command manually, and it worked.