/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 (to my understanding). 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 disable-rendering-on-unmount # fetch will succeed, but not affect the repo
git reset --hard disable-rendering-on-unmount # will fail with the same error as shown above
git fetch -n origin disable-rendering-on-unmount:disable-rendering-on-unmount
git reset --hard disable-rendering-on-unmount # 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 (to my understanding). Providing a local branch to track the remote from will fix this, however.Simple demonstration of the issue: