6

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
Arpit Aggarwal
  • 21,748
  • 13
  • 80
  • 99
Adeel
  • 2,066
  • 1
  • 17
  • 28

2 Answers2

4

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.

Azot
  • 91
  • 1
  • 7
  • 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. – Claytog Jun 30 '20 at 01:34
  • @Claytog if this is so then add your comment as an edit to the answer. – Adeel Jul 14 '20 at 16:21
1

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
Arpit Aggarwal
  • 21,748
  • 13
  • 80
  • 99
  • 1
    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.json` – Adeel Jan 06 '17 at 08:52
  • run `git update-index --no-assume-unchanged ` with full path and file name, as `git update-index --no-assume-unchanged /path/to/directory/.xcassets/Contents.json` – Arpit Aggarwal Jan 06 '17 at 09:40
  • Didn't work either. `fatal: Not a git repository (or any of the parent directories): .git` – Adeel Jan 06 '17 at 09:48
  • this error because you are not executing the command - `/path/to/directory/.xcassets/Contents.json` from your project directory – Arpit Aggarwal Jan 06 '17 at 13:03
  • See my first comment. When I execute this command from the project folder it shows that error. – Adeel Jan 06 '17 at 13:15
  • 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. – Adeel Jan 06 '17 at 13:28
  • There is also the `.gitignore_global` file - check it out. In our case it was the reason. – Radek Wilczak Apr 16 '20 at 12:19