GIT 1.9 - remote: error: 'receive.denyCurrentBranch'
I have an error while using Git 1.9.
When I try to "git push" I get the following error:
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
So my first step was to read a lot here in this forum and tried to find some results from google. Unfortunately everything I've found doesn't work in my case.
I am working on Linux x86 and have Git 1.9 installed.
I can " git clone
" one repository from my server and work in it.
For example, I " touch testfile
" in it to create a new file. Now I will " git commit
" this file.
After this step I " git push
" and then get an error code.
In another article I found that the problem was solved in Git 2.3 And that it is useful to change the value from " receive.denyCurrentBranch
" in the config file from the repository. Useful values should be: refuse
, updateInstead
andignore
I've tried them all and the error will always be the same.
On the server, the configuration value ist:
[receive]
denyCurrentBranch = refuse
and " git branch
"
*master
On the client " git status
":
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
So the error will pop up anytime, I really don't know how to fix it.
How can I avoid this error message?
source to share
A general recommendation would be to create a bare repo on your server ( or convert an existing repo to a bare one ), clone it, add and commit new files, then push.
This push will not contain a description of the error. git init --bare
Note that any function ( 2.3receive.denyCurrentBranch updateInstead
or 2.4 push-to-deploy ) that allows for pushing to a non-bare repo is not in Git 1.9.
You should be able to install the latest Git 2.13 from the right ppa .
source to share
As a git post will prompt you that 'receive.denyCurrentBranch' is not recommended.
We usually control the version using git with a remote repo and a local repo. And the remote repo is where git is actually version controlled. Usually the remote repo is open.
So the recommended method is converting the remote repo as a mountain on your server and treating it as a remote repo
git clone <URL of repo> --bare
, now work like a remote repo for it.
Now you can clone the above main repo and commit / push to it.
source to share