I'm using git annex sync to keep the master
branch of various remotes in sync. Predictably, while the synced/master
branch gets synced fine, the machine running git annex sync fails to push to the remote's master
branch, since it's currently checked out:
ok
push indian
Everything up-to-date
remote: error: refusing to update checked out branch: refs/heads/master
To ssh://indian-wired/home/adam/org
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://adam@indian-wired/home/adam/org'
Is there a way to get annex sync to only try to push to the remote's synced/master
and not master
? I see the --no-push
option, but presumably this would prevent pushing to both, which is obviously not what I want.
I don't think there's a way to do that. I think your main options are
set
receive.denyCurrentBranch
to "updateInstead" orhandle the pushing and fetching yourself. Follow up with a
git annex merge
or with agit annex sync
invocation that prevents it from pushing/pulling.I haven't used it myself, but my understanding is that
sync
s recently added--only-annex
is intended to support this case and frees you from worrying about managing git-annex branches.Usually, git-annex detects this situation and hides the error message from the git push of master.
It only hides the error message if it mentions "denyCurrentBranch". The usual error message in this situation does. I think there must be something in the git configuration (on the remote) that does not.
Perhaps something to do with receive.denyCurrentBranch? Yes, it seems that if it's set to "refuse", I get the same error.
It would be nice if git-annex could recognize that error and hide it too, which I suppose would involve looking for "refusing to update checked out branch", and probably would need git to be run with localization disabled.
If you can unset receive.denyCurrentBranch in the remote's git config, it will avoid the problem for you..
refuse
globally in~/.gitconfig
. I definitely don't want to unset it since that could really screw up my working trees. Your idea of disabling localization (LANG=C
or similar, I guess?) and checking for "refusing to update checked out branch" sounds reasonable, but I would prefer a way to just stop it even trying to update anything other thansynced/$BRANCH
.