git-directory-deploy icon indicating copy to clipboard operation
git-directory-deploy copied to clipboard

Refusing to fetch into current branch refs/heads/master of non-bare repository

Open leodido opened this issue 9 years ago • 4 comments

The following command

GIT_DEPLOY_DIR=deploy \
GIT_DEPLOY_BRANCH=master \
GIT_DEPLOY_REPO=https://<token>@github.com/<org>/<org>.github.io.git \
git-directory-deploy --verbose -m 'New: Deploy'

gives the following error

fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository

Any idea?

I think it depends on the fact that I'm pushing to the master branch (of another repository) while I am on the master locally.

leodido avatar Jul 08 '16 22:07 leodido

I had the same problem. In my repo I had only the gh-pages branch. What I did was create and checkout the master branch and execute the deploy.sh.

See the difference between the branches: https://github.com/taquarivalley/conectado-iot

edpittol avatar Jul 27 '16 13:07 edpittol

hi, @leodido, sorry for the delay in responding. (looks like I messed up again last time I messed with my notification settings.) You are correct that the error is because you are on master while deploying to master; the script doesn't expect that. I'm guessing you're working in a separate repo with the source files and only using the GitHub pages repo to deploy the production files. The script is designed on the assumption that you are working in a clone of the remote repo, so that the deploy branch exists in both repos with the same name.

I suppose your use case could be supported if we allowed the deploy branch to be specified as a local / remote pair, like in the git push command, but I can't promise I'll ever get around to implementing that.

X1011 avatar Aug 25 '16 08:08 X1011

Note for future Googlers, I ended up with this error when i tried to git-directory-deploy while my internet connection was down. My deploy script switched over to my gh-pages branch, failed, and then stayed on that branch; when I restored my internet connection and ran it again I was still on the gh-pages branch.

That caused the error described here, trying to fetch the current branch. Resetting and checking out master resolved the problem for me.

ericsoco avatar Apr 24 '17 03:04 ericsoco

I also face the same problem

this answer clear all the doubt

https://stackoverflow.com/questions/29028696/why-git-fetch-origin-branchbranch-works-only-on-a-non-current-branch

inyee786 avatar Oct 25 '18 11:10 inyee786