Home > Back-end >  EGIT Can't connect to any repository - Missing unknown
EGIT Can't connect to any repository - Missing unknown

Time:10-20

I just created a new repository on GitHub and trying to initially push my local Java project.
I added the ssh key in my GitHub account, and it's referenced correctly by Eclipse, I assume.

I only get this error message when I'm trying to push:

Can't connect to any repository:
[email protected]:MaximStein/MyProject.git
([email protected]:MaximStein/MyProject.git: Missing unknown
366362as232d670123a2267b4879bbd01d142426)

Any ideas?

CodePudding user response:

Try first if the push would succeed from command line (which means you need in to install Git first):

  • check you are correctly identified with ssh -Tv [email protected]
  • check your remote origin URL: git remote -v
  • check your local status (git status: to make sure you are on a branch, here I assume main, and that you have made at least one commit)
  • check your initial push: git push -u origin main

Check also if you have declared any submodules (.gitmodules file), or look for any nested Git repository (.git subfolder anywhere beside your repository root folder)

It is helpful to rule out (or not) a git-core issue, before investigation an Egit/JGit one.

And the OP Maxim confirms in the comments:

It's a good idea to try it in the command line first.

It says "fatal: bad object HEAD" when I do git status.
I think I've only made one local commit for that project.

Indeed, making local commits, in a branch, is a prerequisite to pushing anything.

CodePudding user response:

Your Git repository seems to be broken or at least in an invalid state.

The root cause seems to be Missing unknown 366362as232d670123a2267b4879bbd01d142426 which means something (probably the HEAD) points to the object with the hash 366362as232d670123a2267b4879bbd01d142426 (which will be stored in the file .git/objects/36/6362as232d670123a2267b4879bbd01d142426) that does not exist.

In the Git History you might right-click the last commit and choose Reset > Soft (HEAD Only). If commits are missing, you might be able to recover them via the Git Reflog view.

Make also sure your Eclipse and EGit/JGit is up to date (for instance, there was an issue causing a Missing unknown error that has been fixed more than four years ago) and that you do a refresh (F5) in Eclipse after you have executed Git operations on the command line.

  • Related