Skip to content

Instantly share code, notes, and snippets.

@gmcinnes
Created August 9, 2014 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmcinnes/62fb765ec09d1c774b52 to your computer and use it in GitHub Desktop.
Save gmcinnes/62fb765ec09d1c774b52 to your computer and use it in GitHub Desktop.
Broken git
# Ok, we have this situation where there's a tree with duplicate file entries. Look:
± |master ✗| → git fsck
Checking object directories: 100% (256/256), done.
error in tree 8f40c81aa8c7698e3888e74c06c9d0ca5d0e71c9: contains duplicate file entries
Checking objects: 100% (89603/89603), done.
# Unfortunately git gc --aggressive --prune won't get rid of it.
# So lets see where that sha gets referenced in the repo:
± |master ✗| → git verify-pack -v .git/objects/pack/pack-255eac73cec9ca3a104dfe618a8f46cadac7a7dd.idx | grep 8f40c81aa
8f40c81aa8c7698e3888e74c06c9d0ca5d0e71c9 tree 5144 2568 1413195
25d65afe7348a396a91f4a8f29ed4ea42692dcb7 tree 43 57 47023938 1 8f40c81aa8c7698e3888e74c06c9d0ca5d0e71c9
aec23253cef91a3e3335f5fb87fad304e9c461bf tree 12 25 47023995 1 8f40c81aa8c7698e3888e74c06c9d0ca5d0e71c9
dae0a6ef458b8a5a867ae6541c42c975a9db78b4 tree 52 69 47024020 1 8f40c81aa8c7698e3888e74c06c9d0ca5d0e71c9
45779c711536557a9b6611155d19304c44d524d4 tree 93 108 47024089 1 8f40c81aa8c7698e3888e74c06c9d0ca5d0e71c9
# Ok a bunch of tree objects seem to have the broken 8f40c81aa as a base-SHA1
# Lets see if we can get some information about them
± |master ✗| → git log --pretty=format:'%T %H' | grep 25d65afe7
± |master ✗| → git log --pretty=format:'%T %H' | grep aec2325
± |master ✗| → git log --pretty=format:'%T %H' | grep dae0a6ef
± |master ✗| → git log --pretty=format:'%T %H' | grep 45779c7
# Hmm. No output from git log.
# Ok. Let's see if we can figure out what's in each tree
± |master ✗| → git ls-tree 45779c7
040000 tree 5f051099dc187af54bac3018250630c07768c76d broken-link-checker
040000 tree 6b8927f64b9b64438d3fd157a8ad372cc098540c google-analyticator
040000 tree 00d9304f796da8a1e59841ef1f589d7495de2f22 gravity-forms-custom-post-types
040000 tree 00f5b1abd8fa662e7a1ff60206411a87b96df66b gravity-forms-salesforce
040000 tree 58048dd1f3ddfa54cc51a4ea6dba06d563f4c4b1 gravityforms-plugins
100644 blob 2b1e07b59e8374eaac9f4fbb6a33176e1d18b263 hello.php
160000 commit 8244f7b1b1aae778801d096216983a0d0186e40a icit_auditlogger
100644 blob 4e6c07c7ee1691cab5336b2f356ff6a5f367f879 index.php
040000 tree 3d8d98b72789936d784d9637e5d0eef0d0131ecc redirection
040000 tree c2de2d7d51afd4e3d283802b76f4a92de3f29ba3 super-cpt
040000 tree 923222b03c42ef26b52edb422d5efab22f5e1022 swiftype-search
040000 tree d27ef710acc67260e186140c4235687450281576 term-management-tools
040000 tree 45ff1c9f771cb517948b387be903617fbdbe85fc wordpress-seo
040000 tree 5ba669d68ec06f376d364d6ba3d0d3cdec5e93bc wp-password-policy-manager
± |master ✗| → git ls-tree dae0a6ef458b8a5a867ae6541c42c975a9db78b4
040000 tree 5f051099dc187af54bac3018250630c07768c76d broken-link-checker
040000 tree 6b8927f64b9b64438d3fd157a8ad372cc098540c google-analyticator
040000 tree 00d9304f796da8a1e59841ef1f589d7495de2f22 gravity-forms-custom-post-types
040000 tree 00f5b1abd8fa662e7a1ff60206411a87b96df66b gravity-forms-salesforce
040000 tree 58048dd1f3ddfa54cc51a4ea6dba06d563f4c4b1 gravityforms-plugins
100644 blob 2b1e07b59e8374eaac9f4fbb6a33176e1d18b263 hello.php
040000 tree a8a7aa34238555bd52351174261fd34c701e00dc icit_auditlogger
160000 commit 60da2fe9ec5fbc6aa48a5c7d3cc2d14dba9d13f9 icit_auditlogviewer
100644 blob 4e6c07c7ee1691cab5336b2f356ff6a5f367f879 index.php
040000 tree 3d8d98b72789936d784d9637e5d0eef0d0131ecc redirection
040000 tree c2de2d7d51afd4e3d283802b76f4a92de3f29ba3 super-cpt
040000 tree 923222b03c42ef26b52edb422d5efab22f5e1022 swiftype-search
040000 tree d27ef710acc67260e186140c4235687450281576 term-management-tools
040000 tree 45ff1c9f771cb517948b387be903617fbdbe85fc wordpress-seo
040000 tree 5ba669d68ec06f376d364d6ba3d0d3cdec5e93bc wp-password-policy-manager
± |master ✗| → git ls-tree aec23253cef91a3e3335f5fb87fad304e9c461bf
040000 tree 5f051099dc187af54bac3018250630c07768c76d broken-link-checker
040000 tree 6b8927f64b9b64438d3fd157a8ad372cc098540c google-analyticator
040000 tree 00d9304f796da8a1e59841ef1f589d7495de2f22 gravity-forms-custom-post-types
040000 tree 00f5b1abd8fa662e7a1ff60206411a87b96df66b gravity-forms-salesforce
040000 tree 58048dd1f3ddfa54cc51a4ea6dba06d563f4c4b1 gravityforms-plugins
040000 tree a8a7aa34238555bd52351174261fd34c701e00dc icit_auditlogger
160000 commit 60da2fe9ec5fbc6aa48a5c7d3cc2d14dba9d13f9 icit_auditlogviewer
100644 blob 4e6c07c7ee1691cab5336b2f356ff6a5f367f879 index.php
040000 tree 3d8d98b72789936d784d9637e5d0eef0d0131ecc redirection
040000 tree c2de2d7d51afd4e3d283802b76f4a92de3f29ba3 super-cpt
040000 tree 923222b03c42ef26b52edb422d5efab22f5e1022 swiftype-search
040000 tree d27ef710acc67260e186140c4235687450281576 term-management-tools
040000 tree 45ff1c9f771cb517948b387be903617fbdbe85fc wordpress-seo
040000 tree 5ba669d68ec06f376d364d6ba3d0d3cdec5e93bc wp-password-policy-manager
± |master ✗| → git ls-tree 25d65afe7348a396a91f4a8f29e
040000 tree 5f051099dc187af54bac3018250630c07768c76d broken-link-checker
040000 tree 6b8927f64b9b64438d3fd157a8ad372cc098540c google-analyticator
040000 tree 00d9304f796da8a1e59841ef1f589d7495de2f22 gravity-forms-custom-post-types
040000 tree 00f5b1abd8fa662e7a1ff60206411a87b96df66b gravity-forms-salesforce
040000 tree 58048dd1f3ddfa54cc51a4ea6dba06d563f4c4b1 gravityforms-plugins
040000 tree a8a7aa34238555bd52351174261fd34c701e00dc icit_auditlogger
040000 tree 84843a4e7691e668342d250c309406881d0a91f6 icit_auditlogviewer
100644 blob 4e6c07c7ee1691cab5336b2f356ff6a5f367f879 index.php
040000 tree 3d8d98b72789936d784d9637e5d0eef0d0131ecc redirection
040000 tree c2de2d7d51afd4e3d283802b76f4a92de3f29ba3 super-cpt
040000 tree 923222b03c42ef26b52edb422d5efab22f5e1022 swiftype-search
040000 tree d27ef710acc67260e186140c4235687450281576 term-management-tools
040000 tree 45ff1c9f771cb517948b387be903617fbdbe85fc wordpress-seo
040000 tree 5ba669d68ec06f376d364d6ba3d0d3cdec5e93bc wp-password-policy-manager
# Ok. We can see there's a reference to this commit 8244f7b1b1aae778801d096216983a0d0186e40a, this commit 60da2fe9ec5fbc6aa48a5c7d3cc2d14dba9d13f9 and this tree 84843a4e7691e668342d250c309406881d0a91f6 and that's all that differs betwen them. So probably those commits still exist, and that's why git gc --aggressive --prune won't throw away the problematic tree.
# Lets see what those commits contain.
± |master ✗| → git show 8244f7b1
fatal: ambiguous argument '8244f7b1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
± |master ✗| → git show 60da2fe9
fatal: ambiguous argument '60da2fe9': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
# Hmm. The commits don't seem to exist. What about the tree?
± |master ✗| → git ls-tree 84843a4e76
040000 tree ab56c45295f065ab31dcec94c371be9eaf168e1a FlashCanvas
100644 blob f3583a757a544582226aa00e8bb917a749e28d71 audit.js
100644 blob 94e00c820c9d0ac26cdeef3971511aa4c62b7262 auditlogviewer.php
100644 blob 17af68ee66ca18c0cd566b3cf651d0b0bbfe8447 auditor-settings.php
100644 blob bea240763eecf93243d201262f044ddf50dd9c3c bootstrap-tooltip.js
100644 blob 51a0c6c15a6c53ca677ae2462788e78eb59b2765 composer.json
040000 tree c7056f16195059ce6819d2ebf3217e2bd07dbc07 css
040000 tree d31b6c8892a716d609190251537d77bf123548bb eventviews
040000 tree 3d2be7b3c30281c28e129f89c42de60f47592024 helpers
100644 blob 90f329ba695d2d61dc6ecd73fef663aac7306c27 icit-auditlogviewer.php
100644 blob 5c787c4a42f0004bc4421a2697a75dfa061cf255 icon16.png
100644 blob 15762e956a408c868f459fea65d03c4b70732b9f iconw16.png
040000 tree ee4ea32c8f1dd68cbd92e514c1abd4c7d507bb1c includes
100644 blob e6fea77505911cf5b7ba63942fae7f0aa059466a jquery.flot.hiddengraphs.js
100644 blob 56f493fbdc7c36ed1bbd3b943f8b7b10a1fed067 jquery.flot.js
100644 blob 4467fc5d8cd31731709691d912355a1a32578b3e jquery.flot.min.js
100644 blob eb568f03ef13bd6cf49e1363af0829f6d7d0dc17 jquery.flot.pie.js
100644 blob b7bf870d759a0c6d8ac0f0d518ef03a140ce667e jquery.flot.pie.min.js
100644 blob 72cf1f1c10dbc4f0014e225030bd3c8b7b9a71c3 jquery.flot.resize.min.js
040000 tree fb1ddf9cff1c930281e3f6730f6f6f0115da1d59 js
040000 tree d6b4b770d7eed77de03033aadc307b8085296add logviews
100644 blob cdf9629c37533cd9210382def81f2b25ad19a308 user.php
100644 blob e20ac34c8bddde901e33201172b007db9fa75422 wp-updates-plugin.php
# Ok. There's a tree there, but how do I get rid of it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment