GIT错误:master -> master (branch is currently checked out)

背景

git服务器搭建后,进行pull和push操作,结果发现无法push

1.错误信息

Could not chdir to home directory /var/services/homes/gaofei: No such file or directory
对象计数中: 3, 完成.
写入对象中: 100% (3/3), 202 bytes | 0 bytes/s, 完成.
Total 3 (delta 0), reused 0 (delta 0)
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: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote: 
remote: You can set 'receive.denyCurrentBranch' configuration variable to
remote: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote: 
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://gaofei@192.168.0.11//volume1/git_prj/ecc
 ! [remote rejected] master -> master (branch is currently checked out)
error: 无法推送一些引用到 'ssh://[email protected]//volume1/git_prj/ecc':错误

2.错误原因

其实出错信息中有提示“remote: ‘receive.denyCurrentBranch’ configuration variable to ‘refuse’.”,即使远程git拒绝了push操作

3.解决办法

修改git服务端的.git/config文件,增加push的设置,添加如下代码:

[receive]
 denyCurrentBranch = ignore

你可能感兴趣的:(git代码管理专栏)