服务端:
创建空的仓库(以项目test为例)
lijun@project /home/pm.git $ mkdir test.git
lijun@project /home/pm.git $ cd test.git/
lijun@project /home/pm.git/test.git $ ls
lijun@project /home/pm.git/test.git $ git --bare init --shared
Initialized empty shared Git repository in /home/pm.git/test.git/
lijun@project /home/pm.git/test.git $ ls
HEAD config description hooks info objects refs
lijun@project /home/pm.git/test.git $
客户端:
此时,git clone时可以用其它用户名(因为此时创建的是共享仓库)
lijun@ubuntu:~/Git_clone$ git clone lijunlzu@project:/home/pm.git/test
Cloning into test...
Password:
warning: You appear to have cloned an empty repository.
lijun@ubuntu:~/Git_clone$ cd test
lijun@ubuntu:~/Git_clone/test$ ls
lijun@ubuntu:~/Git_clone/test$ echo "This git storage for test." > README
lijun@ubuntu:~/Git_clone/test$ git add README
lijun@ubuntu:~/Git_clone/test$ git commit -m "init git storage." README
[master (root-commit) 4d9fe6d] init git storage.
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README
lijun@ubuntu:~/Git_clone/test$ git pull
Password:
Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched.
lijun@ubuntu:~/Git_clone/test$ git push origin master
Password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 235 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To lijunlzu@project:/home/pm.git/test
* [new branch] master -> master
创建空的仓库(以项目test为例)
lijun@project /home/pm.git $ mkdir test.git
lijun@project /home/pm.git $ cd test.git/
lijun@project /home/pm.git/test.git $ ls
lijun@project /home/pm.git/test.git $ git --bare init --shared
Initialized empty shared Git repository in /home/pm.git/test.git/
lijun@project /home/pm.git/test.git $ ls
HEAD config description hooks info objects refs
lijun@project /home/pm.git/test.git $
客户端:
此时,git clone时可以用其它用户名(因为此时创建的是共享仓库)
lijun@ubuntu:~/Git_clone$ git clone lijunlzu@project:/home/pm.git/test
Cloning into test...
Password:
warning: You appear to have cloned an empty repository.
lijun@ubuntu:~/Git_clone$ cd test
lijun@ubuntu:~/Git_clone/test$ ls
lijun@ubuntu:~/Git_clone/test$ echo "This git storage for test." > README
lijun@ubuntu:~/Git_clone/test$ git add README
lijun@ubuntu:~/Git_clone/test$ git commit -m "init git storage." README
[master (root-commit) 4d9fe6d] init git storage.
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README
lijun@ubuntu:~/Git_clone/test$ git pull
Password:
Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched.
lijun@ubuntu:~/Git_clone/test$ git push origin master
Password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 235 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To lijunlzu@project:/home/pm.git/test
* [new branch] master -> master
lijun@ubuntu:~/Git_clone/test$
新的git仓库建立完成!