I have a local git repository on my Mac that is managed by Xcode. I recently created a new branch and have made a lot of changes since then. I was about to perform my first commit to this new branch and was presented with an error dialog:
The working copy "app name" failed to commit files.
error: invalid object 100644
888688965... for 'Supporting Files/animage.png'
error: Error building trees
I searched the Interwebs for a solution and found this question which appears to be the same issue. I tried both answers to this question and neither solved the problem for me. I have done everything I can think of to solve the problem but have not been successful.
git reset --hard
and this removed uncommitted changes, but after doing so I cannot commit a simple change. The exact same error message is presented.The working copy "app name" failed to commit files.
fatal: unable to read tree 781d...
After running git fsck --full
I see there are several broken links from trees, a lot of dangling blobs, several missing blobs, and two missing trees.
The result of git for-each-ref --format='%(refname)' | while read ref; do git rev-list --objects $ref >/dev/null || echo "in $ref"; done
:
fatal: missing blob object '8886889658056c4ce52d46a485933c8df7a4de84'
in refs/heads/UniversalStoryboard
fatal: missing blob object '8886889658056c4ce52d46a485933c8df7a4de84'
in refs/heads/Update1
fatal: missing blob object '8886889658056c4ce52d46a485933c8df7a4de84'
in refs/heads/iOS-8-Update
fatal: missing blob object '8886889658056c4ce52d46a485933c8df7a4de84'
in refs/heads/master
After attempting to clone the repo, this is what is logged:
error: unable to read sha1 file of appname/Images.xcassets/AppIcon.appiconset/Icon-Small-1.png (86672e7aa0d5ad36563feef30c15a5d31f921802)
error: unable to read sha1 file of appname/Images.xcassets/AppIcon.appiconset/Icon-Small.png (86672e7aa0d5ad36563feef30c15a5d31f921802)
error: unable to read sha1 file of appname/Images.xcassets/LaunchImage.launchimage/[email protected] (7d97eba35cf392ddb1a705109b721fcd6a20ea29)
error: unable to read sha1 file of appname/appname-Prefix.pch (82a2bb45076d290ce7461b28d5a579e649777779)
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
At this point in time I am willing to do anything to prevent having to trash the entire git repository and start over. I don't want to lose my branches and history. How can I fix this issue? I have a working copy of the project directory exactly as it was when I first discovered the error as well as Time Machine backups for the entire history of this project. Anything you can suggest is appreciated.
One fix is to:
If you had previously pushed your repo, try cloning the remote repo instead of the local one.
Or try cloning the repo as save by Time machine.
If that doesn't work, you have a broken repo, and you can try some of the methods exposed in "Tree contains duplicate file entries".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With