Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem. My laptop ran out of battery during a git operation. Boo. </p> <p>I didn't have any backups. (N.B. Ubuntu One is not a backup solution for git; it will helpfully overwrite your sane repository with your corrupted one.)</p> <p>To the git wizards, if this was a bad way to fix it, please leave a comment. It did, however, work for me... at least temporarily. </p> <p>Step 1: Make a backup of .git (in fact I do this in between every step that changes something, but with a new copy-to name, e.g. .git-old-1, .git-old-2, etc.): </p> <pre><code>cp -a .git .git-old </code></pre> <p>Step 2: Run <code>git fsck --full</code></p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git fsck --full error: object file .git/objects/8b/61d0135d3195966b443f6c73fb68466264c68e is empty fatal: loose object 8b61d0135d3195966b443f6c73fb68466264c68e (stored in .git/objects/8b/61d0135d3195966b443f6c73fb68466264c68e) is corrupt </code></pre> <p>Step 3: Remove the empty file. I figured what the heck; its blank anyway. </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ rm .git/objects/8b/61d0135d3195966b443f6c73fb68466264c68e rm: remove write-protected regular empty file `.git/objects/8b/61d0135d3195966b443f6c73fb68466264c68e'? y </code></pre> <p>Step 3: Run <code>git fsck</code> again. Continue deleting the empty files. You can also <code>cd</code> into the <code>.git</code> directory and run <code>find . -type f -empty -delete -print</code> to remove all empty files. Eventually git started telling me it was actually doing something with the object directories: </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git fsck --full Checking object directories: 100% (256/256), done. error: object file .git/objects/e0/cbccee33aea970f4887194047141f79a363636 is empty fatal: loose object e0cbccee33aea970f4887194047141f79a363636 (stored in .git/objects/e0/cbccee33aea970f4887194047141f79a363636) is corrupt </code></pre> <p>Step 4: After deleting all of the empty files, I eventually came to <code>git fsck</code> actually running: </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git fsck --full Checking object directories: 100% (256/256), done. error: HEAD: invalid sha1 pointer af9fc0c5939eee40f6be2ed66381d74ec2be895f error: refs/heads/master does not point to a valid object! error: refs/heads/master.u1conflict does not point to a valid object! error: 0e31469d372551bb2f51a186fa32795e39f94d5c: invalid sha1 pointer in cache-tree dangling blob 03511c9868b5dbac4ef1343956776ac508c7c2a2 missing blob 8b61d0135d3195966b443f6c73fb68466264c68e missing blob e89896b1282fbae6cf046bf21b62dd275aaa32f4 dangling blob dd09f7f1f033632b7ef90876d6802f5b5fede79a missing blob caab8e3d18f2b8c8947f79af7885cdeeeae192fd missing blob e4cf65ddf80338d50ecd4abcf1caf1de3127c229 </code></pre> <p>Step 5: Try <code>git reflog</code>. Fail because my HEAD is broken. </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git reflog fatal: bad object HEAD </code></pre> <p>Step 6: Google. Find <a href="http://git.661346.n2.nabble.com/corrupted-Git-repository-td6498902.html" rel="noreferrer">this</a>. Manually get the last two lines of the reflog: </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ tail -n 2 .git/logs/refs/heads/master f2d4c4868ec7719317a8fce9dc18c4f2e00ede04 9f0abf890b113a287e10d56b66dbab66adc1662d Nathan VanHoudnos &lt;nathanvan@gmail.com&gt; 1347306977 -0400 commit: up to p. 24, including correcting spelling of my name 9f0abf890b113a287e10d56b66dbab66adc1662d af9fc0c5939eee40f6be2ed66381d74ec2be895f Nathan VanHoudnos &lt;nathanvan@gmail.com&gt; 1347358589 -0400 commit: fixed up to page 28 </code></pre> <p>Step 7: Note that from Step 6 we learned that the HEAD is currently pointing to the very last commit. So let's try to just look at the parent commit:</p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git show 9f0abf890b113a287e10d56b66dbab66adc1662d commit 9f0abf890b113a287e10d56b66dbab66adc1662d Author: Nathan VanHoudnos &lt;nathanvan@XXXXXX&gt; Date: Mon Sep 10 15:56:17 2012 -0400 up to p. 24, including correcting spelling of my name diff --git a/tex/MCMC-in-IRT.tex b/tex/MCMC-in-IRT.tex index 86e67a1..b860686 100644 --- a/tex/MCMC-in-IRT.tex +++ b/tex/MCMC-in-IRT.tex </code></pre> <p>It worked!</p> <p>Step 8: So now we need to point HEAD to 9f0abf890b113a287e10d56b66dbab66adc1662d. </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git update-ref HEAD 9f0abf890b113a287e10d56b66dbab66adc1662d </code></pre> <p>Which didn't complain.</p> <p>Step 9: See what fsck says:</p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git fsck --full Checking object directories: 100% (256/256), done. error: refs/heads/master.u1conflict does not point to a valid object! error: 0e31469d372551bb2f51a186fa32795e39f94d5c: invalid sha1 pointer in cache-tree dangling blob 03511c9868b5dbac4ef1343956776ac508c7c2a2 missing blob 8b61d0135d3195966b443f6c73fb68466264c68e missing blob e89896b1282fbae6cf046bf21b62dd275aaa32f4 dangling blob dd09f7f1f033632b7ef90876d6802f5b5fede79a missing blob caab8e3d18f2b8c8947f79af7885cdeeeae192fd missing blob e4cf65ddf80338d50ecd4abcf1caf1de3127c229 </code></pre> <p>Step 10: The invalid sha1 pointer in cache-tree seemed like it was from a (now outdated) index file (<a href="http://www.spinics.net/lists/git/msg96103.html" rel="noreferrer">source</a>). So I killed it and reset the repo.</p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ rm .git/index nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git reset Unstaged changes after reset: M tex/MCMC-in-IRT.tex M tex/recipe-example/build-example-plots.R M tex/recipe-example/build-failure-plots.R </code></pre> <p>Step 11: Looking at the fsck again...</p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git fsck --full Checking object directories: 100% (256/256), done. error: refs/heads/master.u1conflict does not point to a valid object! dangling blob 03511c9868b5dbac4ef1343956776ac508c7c2a2 dangling blob dd09f7f1f033632b7ef90876d6802f5b5fede79a </code></pre> <p>The <a href="https://stackoverflow.com/questions/9955713/git-dangling-blobs">dangling blobs are not errors</a>. I'm not concerned with master.u1conflict, and now that it is working I don't want to touch it anymore! </p> <p>Step 12: Catching up with my local edits: </p> <pre><code>nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git status # On branch master # Changes not staged for commit: # (use "git add &lt;file&gt;..." to update what will be committed) # (use "git checkout -- &lt;file&gt;..." to discard changes in working directory) # # modified: tex/MCMC-in-IRT.tex # modified: tex/recipe-example/build-example-plots.R # modified: tex/recipe-example/build-failure-plots.R # &lt; ... snip ... &gt; no changes added to commit (use "git add" and/or "git commit -a") nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git commit -a -m "recovering from the git fiasco" [master 7922876] recovering from the git fiasco 3 files changed, 12 insertions(+), 94 deletions(-) nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git add tex/sept2012_code/example-code-testing.R nathanvan@nathanvan-N61Jq:~/workspace/mcmc-chapter$ git commit -a -m "adding in the example code" [master 385c023] adding in the example code 1 file changed, 331 insertions(+) create mode 100644 tex/sept2012_code/example-code-testing.R </code></pre> <p>So hopefully that can be of some use to people in the future. I'm glad it worked.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload