git push提交时报错,拒绝提交

今天初次创建了git项目,并尝试将代码提交,但是报错,一直拒绝提交,错误如下:

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'.  
To [email protected]:ldlogistics.git  
 ! [remote rejected] master -> master (branch is currently checked out)  
error: failed to push some refs to '[email protected]:ldlogistics.git'


在网上查了很久,最终解决办法如下:

在服务器的ldlogistics.git中有隐藏文件夹.git  ,修改.git下的config文件,在文件末尾添加

[receive]
    denyCurrentBranch = ignore  

然后就能提交了(先是修改了本地的该文件,但是没有生效,后来修改了服务器上的就好了,也不知道是否两个地方都需要改或是只需要改服务器的)

你可能感兴趣的:(#,git)