【发布时间】:2015-08-23 19:10:09
【问题描述】:
我的计算机上已经有一个 Git 存储库。我想在我的计算机中为此设置一个远程存储库,例如在/path/to/remote。
所以我使用git init来启动一个空的存储库。然后我使用了这个命令:
$ git remote add test "file:///path/to/remote/.git/"
然后尝试:
$ git push -u test --all
但这会导致错误:
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 file:///path/to/remote/.git/
! [remote rejected] master -> master (branch is currently checked out)
我该如何解决这个问题?
编辑:
作为this question 提议的答案,我尝试推送到非签出分支并解决了问题。
【问题讨论】:
标签: git repository git-push