我根据这里的说明设置了git .但是,在创建测试文件,提交它并将其推送到服务器之后,我在git目录下的任何地方都看不到该文件.我希望它会出现在机器上的Web服务器可以看到它的某个地方,这样推送会立即显示出对服务器的http请求.
我知道git应该是更自包含的,在客户端,文件形成一个可以这种方式使用的很好的包.服务器不做同样的事情吗?
更新:我最初没有使用"裸"选项.但是当我这样做,并且我尝试从远程执行初始提交时,我收到了一条我不太了解的重大错误消息.
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'.
由于我从未检查过任何东西,我不知道这是什么意思,或者我应该做什么.
在您的客户端看起来似乎是一个存储库实际上是两件事.实际存储库位于.git
您的工作树中,通常包含与当前检出的提交相对应的文件.
两者都很独立.工作树仅用于进行更改并在之后更新存储库.
即使它首先看起来像你在你的"存储库"中,你实际上在你的工作树中.从那里,您可以询问存储库以更新文件或将文件添加到存储库中的新提交. - 但是您的存储库本身永远不会改变您的工作树.
您的远程存储库是一个裸存储库,即它只是没有工作树的存储库.这是为了能够推送任意分支所需要的.
因为缺少工作树,所以无法在任何地方看到文件.(即使有一些工作树,也不清楚要显示哪些文件.毕竟你的存储库包含许多提交,所有提交都有不同的内容.)
要实际"查看"这些文件,最简单的方法是将存储库克隆到Web服务器的目录中,并检查正确的分支. - 当主存储库发生变化时,您需要更新此存储库.这可以通过在主存储库中使用钩子来实现.一个后收到钩将是在这种情况下的罚款.