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

2

8

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
Ramah answered 6/1, 2017 at 6:39 Comment(6)
Would you mind copy & pasting the contents of your repo's ".gitignore" file (if it has one)?Slew
@G.SylvieDavies there is no .gitignore file. The .git folder contains hooks, info, logs, objects, and refs as subfolders and some other files like config, HEAD etc.Ramah
".gitignore" would be in "./.gitignore" (top folder) and not anywhere under ".git/*".Slew
@adeel .gitignore is in your project rootZwickau
Most likely the file is being ignored. Use git check-ignore Contents.json to find out where the ignore rule comes from.Kristelkristen
@Kristelkristen it prints Contents.json.Ramah
P
9

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.

Precess answered 5/6, 2020 at 21:28 Comment(3)
Thank you, this was so helpful, however needed this with full stop character "git add -f ." then all the ignored "Contents.json" files were added to git.Respecting
@Respecting if this is so then add your comment as an edit to the answer.Ramah
You are a lifesaver, man !!Gothurd
B
3

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
Bacteriophage answered 6/1, 2017 at 7:28 Comment(8)
I have updated the question with the contents of .gitignore. and .git/info/exclude files. I'm not sure where I can fine the ~/.gitexclude file. Tried the command that you suggested but it threw this error fatal: Unable to mark file .xcassets/Contents.jsonRamah
run git update-index --no-assume-unchanged <file> with full path and file name, as git update-index --no-assume-unchanged /path/to/directory/.xcassets/Contents.jsonBacteriophage
Didn't work either. fatal: Not a git repository (or any of the parent directories): .gitRamah
this error because you are not executing the command - /path/to/directory/.xcassets/Contents.json from your project directoryBacteriophage
See my first comment. When I execute this command from the project folder it shows that error.Ramah
I appears that the required path to the directory is relative to the project directory and not the absolute path. However, the problem still remains. The said file is still not in the list of files.Ramah
There is also the .gitignore_global file - check it out. In our case it was the reason.Needleful
@RadekWilczak, .gitignore_global , there was the issueStaysail

© 2022 - 2024 — McMap. All rights reserved.