git push 的时候出错branch is currently checked out
1.问题描述:在本地服务器搭建了git 之后,在客户端主机使用git push 出现如下错误:jyq@jyq:~/work/Git/Robot$ git push origin master对象计数中: 5, 完成.Delta compression using up to 4 threads.压缩对象中: 100% (5/5), 完成.写入对象中: 100% (5/5), 669 by...
·
1.问题描述:
在本地服务器搭建了git 之后,在客户端主机使用git push 出现如下错误:
jyq@jyq:~/work/Git/Robot$ git push origin master
对象计数中: 5, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (5/5), 完成.
写入对象中: 100% (5/5), 669 bytes | 0 bytes/s, 完成.
Total 5 (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: 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 git@192.168.30.11:/home/git/Code/Robot
! [remote rejected] master -> master (branch is currently checked out)
error: 无法推送一些引用到 'git@192.168.30.11:/home/git/Code/Robot'
2.解决办法:
这是由于git默认拒绝了push操作,在远程服务器主机执行如下命令:
git config receive.denyCurrentBranch ignore
或者在.git/config中添加如下代码:
[receive]
denyCurrentBranch = ignore
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献2条内容
所有评论(0)