我按照这里的说明安装了git。然而,我创建了一个测试文件,提交并推送到服务器后,发现在git目录下找不到该文件。我希望文件能出现在机器上的web服务器可见的某个位置,以便通过http请求立即显示推送。
我知道git应该更加自包含,在客户端方面文件形成了一个可以用于此方式的良好包。服务器为什么不做同样的事情呢?
更新:我最初没有使用“bare”选项。但当我这样做,并尝试从远程进行初始提交时,我得到了一个我不太理解的巨大错误消息。
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'.
由于我从未检查过任何东西,所以我不知道它的意思或者我真正应该做什么。
--bare
参数创建了服务器的代码仓库,它告诉Git“不要保留该仓库的工作副本”。没有工作副本,文件(实际上是定义这些文件的对象)只存在于.git
目录中。 - Chris Hayesgit config receive.denyCurrentBranch ignore
。 - Chris Hayes