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 git@github.com
- 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.
In your case, do a git branch -avv
to check if there are any.
If you already pushed that missing commit, assuming your main branch is main
(not master
):
git fetch origin
git reset --soft origin/main