Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: bad config value for 'receive.denycurrentbranch' in ./config

Tags:

git

git-config

I use git to push commited changes to a repo that lies on a server. Now there is this Error:

$ git push -u origin master
fatal: bad config value for 'receive.denycurrentbranch' in ./config
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What it looks like in the console Window

Now I suppose that this error might be due to some failures in the SSH connection. I use PuTTY to connect via SSH to my webserver. However, I'm still a noob and i don't know exactly how this works.

So what I've tried is that I genereated the private key online, downloaded it, translated it into PPK-Format and put it in the authentication tab in PuTTY. When i log in via PuTTY i have to put in key passphrase and then it manages to connect without error.

The error is only in git bash. So how do I fix it there? Do somehow need to tell Git to use PuTTY as my SSH agent (what is an SSH agent anyway?). Or is Git by default using OpenSSH from Windows 10?

I've also tried to use

$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa

but I don't exactly know what it does. Does it just start the OpenSSH-Agent?

If someone could clear things up a bit for me i would be more than happy. I have been googling for about a day and while pieces slowly come together, I wasn't able to solve that particular problem. Thanks! :)

Update 19.7.19

The Problem is still not solved entirely. Yes, setting receive.denycurrentbranch to ignore or refuse on the server side makes the error disappear. I can push, however there are no files showing. Apparently, only commits are saved in the repo and not the files themselves. As I figured, I need the updateInstead option which allows for non-bare repos (repository with actual files instead of just commits) to exist, so that the server can take these files from the repo and deploy them in my public_html-folder.

My server git version is 2.19.1, which is seemingly higher than the 2.4.0 version which is required to interpret the updateInstead-Parameter. So it's still a mystery to me why this error appears.

I'm right now trying to install a new git version on my server just to see if that changes anything. However, I encountered a different problem there. Please visit this thread.

like image 867
glades Avatar asked Jul 11 '19 13:07

glades


Video Answer


1 Answers

I know this is an old issue, but I have solved it and wanted to post the solution for others.

The issue appears to be that there are 2 git installations on your hosting provider. One is installed in \usr\bin and used by default. This one is probably 1.8.* or something earlier than 2.4. The other is installed in the cpanel app directory and is linked in your path. Because git doesn't run a full shell, the default 'old' version is used rather than the one that you get back from git version when you run in an ssh session . To fix this first look at the path of the git-receive-pack under your ssh session:

which git-receive-pack 

Than on your local machine update your remote config:

git config remote.<remote-name>.receivepack <receive-pack-path>

That should fix your problem.

like image 138
Aaron Dalton Avatar answered Sep 29 '22 01:09

Aaron Dalton