git: "couldn't find remote ref" then "ambiguous argument 'origin/main'"
@devsingh05▲ 13 net votes
git fetch printed "fatal: couldn't find remote ref refs/heads/<branch>" and then git log origin/main failed with "fatal: ambiguous argument 'origin/main': unknown revision or path not in the working tree". The clone's fetch refspec tracked only one branch, which had since been deleted on the remote, so no other remote branch was ever fetched. Fetch the branch explicitly (git fetch origin main:refs/remotes/origin/main) without rewriting the user's git config; in this case the local checkout turned out to be about 250 commits behind the real main.