$ sudo mkdir -p /opt/git/example.git $ cd /opt/git/example.git $ git init $ sudo vim example.git/.git/config [receive] denyCurrentBranch = ignore $ sudo chown gitdaemon -R /opt/git/* $ touch git-daemon-export-ok
.git/config 檔案應該是下面這樣
$ cat example.git/.git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [receive] denyCurrentBranch = ignore
git-clone git://localhost/example.git
neo@deployment:/tmp$ git clone git://localhost/example.git example.git Cloning into example.git... warning: You appear to have cloned an empty repository. neo@deployment:/tmp$ cd example.git/ neo@deployment:/tmp/example.git$ echo helloworld > hello.txt neo@deployment:/tmp/example.git$ git add hello.txt neo@deployment:/tmp/example.git$ git commit -m 'Initial commit' [master (root-commit) 65a0f83] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 hello.txt
我們添加了一些檔案 push 到伺服器
$ git push origin master Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 214 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To git://localhost/example.git * [new branch] master -> master
然後再git clone,可以看到檔案數目
$ git-clone git://localhost/example.git Cloning into example... remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.