【发布时间】:2017-05-10 14:26:21
【问题描述】:
我在 mac os x 上,启用了 ssh。我试图将本地更改推送到远程仓库。我在本地模拟远程仓库是这样的:创建远程仓库
$cd ~/learn
$mkdir gittest
$cd gittest/
$git init
$git config --global user.name "username"
$git config --global user.email "useremail"
$touch readme
$git add readme
$git commit -m "empty"
好的,一切都很好,然后在另一个目录中,我做了:
$cd ~/learn/client
$git clone trosky@localhost:/Users/trosky/learn/gittest
$cd gittest
$vi readme(add one line)
$git add .
$git commit -m "add line"
$git push origin master:refs/heads/master
它失败了,git 说:
$git push origin master:refs/heads/master
Total 0 (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 x@localhost:/Users/trosky/gittest
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'x@localhost:/Users/trosky/learn/gittest'
这是否表明远程仓库或本地客户端有任何问题?如何解决?
【问题讨论】:
-
该消息准确地说明了发生了什么,你能解释一下它的哪一部分让你感到困惑吗?