/usr/bin/git fetch -n origin main
From https://github.com/preactjs/preact
* branch main -> FETCH_HEAD
* [new branch] main -> origin/main
successfully fetched base.ref
checking out and building base commit
/usr/bin/git reset --hard main
fatal: ambiguous argument 'main': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
As the repo is a shallow clone, fetches will only update the remote branch tracking the currently cloned branch, i.e., git fetch <another branch> won't have any effect. Providing a local branch to track the remote from will fix this, however.
Simple demonstration of the issue:
git clone git@github.com:preactjs/preact.git --depth=1
cd preact
git fetch -n origin v11 # fetch will succeed, but not affect the repo
git reset --hard v11 # will fail with the same error as shown above
git fetch -n origin v11:v11
git reset --hard v11 # will succeed
As the repo is a shallow clone, fetches will only update the remote branch tracking the currently cloned branch, i.e.,
git fetch <another branch>
won't have any effect. Providing a local branch to track the remote from will fix this, however.Simple demonstration of the issue: