我的计算机上已经有了一个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提供的答案一样,我尝试 推送到未经检查的分支 并解决了问题。
答案 0 :(得分:2)
确保远程存储库是裸存储库
git init --bare
然后你可以推进它
git push -u file:///path/to/remote/ --all