我正在按照这里的示例 http://wiki.dreamhost.com/Git
基本上我想创建一个 git repo,我可以从我的桌面推送到服务器上......在主机上:
[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 remote add origin 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 文件。
我以前做过这个,它是这样工作的……只是这一次我一定做错了什么。
更新
如果我尝试在没有 --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
基本上使用 --bare 然后有钩子将您的最新提交复制到工作目录!