When calling git fetch --update-head-ok origin develop:develop
from a Bash script I get the following error
fatal: no path specified; see 'git help pull' for valid url syntax
But if I execute this Git command from Bash prompt
$ git fetch --update-head-ok origin develop:develop
I get no error message. I have verified that origin is correctly configured and I have also tried this variant from within the script (URI ssh://git@bitbucket....:7999
is a placeholder for an internal URI to a local Bitbucket server)
git fetch --update-head-ok ssh://git@bitbucket....:7999 develop:develop
which instead gives the error message
fatal: invalid refspec 'ssh://git@bitbucket....:7999'
But the exact same command line works without any problems from Bash prompt.
If I leave out --update-head-ok
in the script I instead get the error message (as expected)
fatal: Refusing to fetch into current branch refs/heads/develop of a non-bare repository
I'm currently using Git 2.35.1 on Centos 7.
Update: I have found the problem. In my script I had a command line that looked like
git fetch --update-head-ok "${force}" origin "${branch}:${branch}"
where $force
could either be an empty string or the string "--force". The result of doing like I did above is an empty argument to git fetch
which it get confused by...