Added:
fetch issue was due to me not understanding how clone --mirror
works, see my answer below.
Original:
I did search. tried to read Git pull after forced update, git refusing to fetch into current branch, How can I recover a lost commit in Git? but still cannot understand my situation.
Both local and remote on main
branch currently (by git status
). git log
on both confirmed local is ahead of remote by 2 commits. Why git fetch apparently tries to update HEAD?
git fetch
fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
fatal: The remote end hung up unexpectedly
git pull
did force update and my main
"lost" recent commits. From linked post I've read to do git reflog
and rest --hard
to last commit and I'm back to square one.
Also currently I face another issue (as initially seeing local is ahead I wanted to push) I've just posted as names match, but: "The upstream branch of your current branch does not match the name of your current branch", git pull wrote "forced update"":
git push
outputs "The upstream branch of your current branch does not match the name of your current branch".
What happened to the repo? Why git pull
does force update by default w/out asking? Why git push
does not find remote branch?
Added:
I continue see some more interesting things, still w/out understanding why git does not see match of main
branches, I did git push origin HEAD:refs/remotes/origin/main
and saw push succeeded:
Total x (delta y)
To remote_url
ref_of_last_remote_commit...ref_of_last_local_commit HEAD -> origin/head
But: git reflog
on remote did not output those new commits!