Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

git - fatal: bad config value for 'receive.denycurrentbranch' in ./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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 usrin 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...