I've been using the following command to update the local master
when I'm not on master
:
git fetch origin master:master
However, today, it stopped working on one of the repo clones I'm working on. It fails with an error:
fatal: refusing to fetch into branch 'refs/heads/master' checked out at '/path/to/project/directory'
On another clone of the same repo it works fine. Any idea what might be the cause? Note that I am not on the master
branch when invoking the command.
I'm on macOS Monterey 12.6 (21G115) with Git 2.38.0 from Homebrew.
More info (anonymized):
$ git worktree list
/path/to/project/directory aa00aa0a0a0 [my-current-branch]
$ git branch -vv
main bb11bb1b1b1 Title of the commit on main
master cc22cc2c2c2 [origin/master] Title of the commit on master
* my-current-branch aa00aa0a0a0 [origin/my-current-branch] Title of the commit on my-current-branch
There are more branches on the list but that shouldn't be relevant. You can see master
& my-current-branch
are up to date and main
is not right now.
Also:
$ git remote show origin
* remote origin
Fetch URL: git@github.com:my-org/my-repo.git
Push URL: git@github.com:my-org/my-repo.git
HEAD branch: master
Remote branches:
main tracked
master tracked
my-current-branch tracked
The output here is huge as we have a lot of branches but other ones should be irrelevant. There's only a single remote: origin
.