问题
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.
回答1:
The problem you're seeing is that you've set an invalid configuration value for the receive.denycurrentbranch
option. It looks like from your console window that you have a version of Git that doesn't understand the refuse
value (or you typed something like a non-breaking space in the value).
You should know that this value only applies to the server side. Setting it on the client side doesn't have any effect whatever. You should remove it from your config by editing the config
(or .git/config
, as appropriate) file and deleting the appropriate option, which should make pushes work again.
回答2:
receive.denycurrentbranch to ignore will not solve problem it will create more problems later i suggest you to follow below steps
This will solve your problem for sure as i wasted my 5 hour in search for the same issue -
First check the GIT VERSION on remote using ssh using command git --version In my case it was 2.19.1 which is this root cause for this problem.
I suggest to create a new repo on cPanel before staring the below process, once you create new repo check following....
Now make sure on remote config denyCurrentBranch = updateInstead below is my remote config screenshot, you can check remote config using command git config --edit when you inside remote repo directory My Live git config screenshot
Now clone the cpanel repo on your local, and check your local git config file and make sure it has the tag [remote "origin"], if you can't find it use this command on your local git remote add origin ssh://username@website/home/username/reponame
Now simply add any test file and commit the changes and push using below command and your remote repo will get updated 100% git push origin master -u --exec=/usr/local/cpanel/3rdparty/bin/git-receive-pack
Regards!
来源:https://stackoverflow.com/questions/56990207/fatal-bad-config-value-for-receive-denycurrentbranch-in-config