我正在按照这里的例子http://wiki.dreamhost.com/Git http://wiki.dreamhost.com/Git
基本上我想创建一个 git 存储库,我可以从桌面推送到服务器上......
在主机上:
[host ~]$ mkdir project.git
[host ~]$ cd project.git
[host project.git]$ git init --bare
[host project.git]$ exit
然后本地:
[local ~]$ cd project
[local project]$ git init
[local project]$ touch .gitignore
[local project]$ git add .
[local project]$ git commit
在主机上,如果我 CD 进入该目录..我会看到以下文件(通常位于 .git 目录中)
HEAD branches config description hooks info objects refs
然后在本地创建远程推送:
git 远程添加源 ssh://XXX@XXX/home/XXX/XXX/
它推动说它已经起作用了......
Counting objects: 3, done.
Writing objects: 100% (3/3), 210 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
但是,当我返回服务器上的工作文件夹时,那里什么也没有......它只是上面列出的 .git 文件。
我以前曾经这样做过,并且是这样工作的......只是这次我一定做错了什么。
UPDATE
如果我尝试在没有 --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'.
更新和解决方案....
我发现这个效果非常好http://toroid.org/ams/git-website-howto http://toroid.org/ams/git-website-howto
本质上使用 --bare 然后使用钩子将最新的提交复制到工作目录!