Git error index file is too small and the upstream is gone

1.3k views Asked by At

I am using GitKraken on Linux for a few years now. And it was working somehow fine so far. But yesterday suddenly I received a message from Gitkraken that they no longer provide a free access to the private repositories!! I was in a hurry and needed to see the differences between my stashed files and my current files, so I ran some weird git scripts regarding that in the terminal. I wasn't successful with that, so I got free trial for GitKraken. Then it worked fine for what I wanted to do and also I was able to pull and push for a day. But yesterday I commited a few files and when I try to pull, it asks: What remote/branch should "my-branch-name" push or pull from? When I write origin/"my-branch-name" and submit it, it gives this error: Cannot read property "fullName" of undefined!

I also tried using git in the terminal; When I run git status, I got the following message:

error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
On branch dev
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
error: index file .git/objects/pack/pack-a08c14513ad1a7f74b2c0ad8883470516745005c.idx is too small
Your branch is based on 'origin/<my-branch-name>', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

nothing to commit, working tree clean

I'm not sure what happened to my git files, whether it comes from Gitkraken or the scripts I ran to see the diffs of the stashed files. There are similar questions in the stackoverflow, but non of them has both of these errors: Index file is too small and also the upstream is gone!

UPDATE:

By applying the suggested "git branch --unset-upstream" in the error message, I was able to pull and push but I still get all the index errors. Beside this, if I try to pull with GitKraken, it fails and then in the terminal by running Git status it will display the same message for upstream:

 "Your branch is based on 'origin/<my-branch-name>', but the upstream is gone." 

So I believe the GitKraken is messing up the git files!

1

There are 1 answers

4
torek On

There are two separate problems:

  1. Your pack index file for the pack file named pack-a08c14513ad1a7f74b2c0ad8883470516745005c.pack was damaged. Exactly what damaged it, and how, is not clear, but it is no longer valid and Git cannot read it.

    If this is the only copy of the repository, look for backups of the entire computer file system, as these may contain good copies of the repository before it got damaged. Also, make a secure copy of the damaged repository (e.g., one or more backup copies on another computer or on USB sticks or whatever backup storage media you have available) before attempting any repairs to it, so that if the repair process makes things worse, you can get back to your less-damaged state.

    Fortunately, a pack index file is something that Git itself generates from the pack file. You can therefore rebuild the index from the pack file, using git index-pack. This assumes that the pack file itself is intact.

    Given that this (index) file has suffered damage, it may be the case that other files have also suffered damage. If you have a backup of this repository, it might be wise to inspect it, and perhaps use it instead of this repository. It might be wise to run git fsck on this repository, to check other files as well.

    This problem produced all of the errors you saw that are prefixed by the word error, so if it can be fixed, you'll be down to a much simpler error.

  2. Perhaps because of the damaged index, or perhaps as a separate item, the remote-tracking name refs/remotes/origin/the-name-you-omitted is missing or otherwise could not be read. This produced the upstream is gone message. This could be entirely normal; see, e.g., Upstream gone message on switching back to an empty master branch?