git 使用例子

此文版权属于作者所有,任何人、媒体或者网站转载、借用都必须征得作者本人同意!

本地仓库

#仓库初始化

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值