此文版權屬於作者所有,任何人、媒體或者網站轉載、借用都必須徵得作者本人同意!
本地倉庫
#倉庫初始化
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