此文版权属于作者所有,任何人、媒体或者网站转载、借用都必须征得作者本人同意!
本地仓库
#仓库初始化
hello@world:~$ su -l git
密码:
git@world:~$ cd /pub/data/02data/git/
git@world:/pub/data/02data/git$ git init --bare myzone.git
初始化空的 Git 版本库于 /pub/data/02data/git/myzone.git/
git@world:/pub/data/02data/git$ exit
注销
#本地工作目录初始化及关联这个仓库
hello@world:~$ cd /pub/job/research/
hello@world:/pub/job/research$ mkdir myzone
hello@world:/pub/job/research$ cd myzone/
hello@world:/pub/job/research/myzone$ git init
初始化空的 Git 版本库于 /pub/job/research/myzone/.git/
hello@world:/pub/job/research/myzone$ touch README.md
hello@world:/pub/job/research/myzone$ git add README.md
hello@world:/pub/job/research/myzone$ git commit -m "Add README.md file"
hello@world:/pub/job/research/myzone$ git remote add origin git@localhost:/pub/data/02data/git/myzone.git
hello@world:/pub/job/research/myzone$ git push origin master
对象计数中: 3, 完成.
写入对象中: 100% (3/3), 236 bytes | 0 bytes/s, 完成.
Total 3 (delta 0), reused 0 (delta 0)
To git@localhost:/pub/data/02data/git/myzone.git
* [new branch] master -> master
hello@world:/pub/job/research/myzone$ git branch --set-upstream-to=origin/master
#测试
hello@world:~$ mkdir tmp
hello@world:~$ cd tmp
hello@world:~/tmp$ git clone /pub/data/02data/git/myzone.git
hello@world:~/tmp$ cd myzone/
hello@world:~/tmp/myzone$ ls -al
总用量 12
drwxrwxr-x 3 hello hello 4096 2月 9 11:23 .
drwxrwxr-x 3 hello hello 4096 2月 9 11:23 ..
-rw-rw-r-- 1 hello hello 0 2月 9 11:23 README.md