通过git remote 建立远程仓库

通过git remote 建立远程仓库

建立远程仓库

1.初始化一个空的git仓库

创建一个文件夹,并进入
执行git init命令
如下显示:
Reinitialized existing Git repository in /home/moran/workspace/gitit/.git/

现在/home/moran/workspace/gitit目录就是git仓库了

2.向仓库提交我们写的文件

software@debian:~/yafeng$ echo "our first git repository" >> file
software@debian:~/yafeng$ ls
file
software@debian:~/yafeng$ git add file
software@debian:~/yafeng$ git commit -m "the first file to commit" file
[master (root-commit) 0c72641] the first file to commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file
software@debian:~/yafeng$ 

3.在本地仓库添加一个远程仓库,并将本地的master分支跟踪到远程分支

software@debian:~/yafeng$ git remote add origin ssh://software@172.16.0.30/~/yafeng/.git
software@debian:~/yafeng$ git push origin master
software@172.16.0.30's password: 
Everything up-to-date
software@debian:~/yafeng$ 

4.测试

software@debian:~/yafeng$ git remote show origin
software@172.16.0.30's password: 
* remote origin
 Fetch URL: ssh://software@172.16.0.30/~/yafeng/.git
 Push  URL: ssh://software@172.16.0.30/~/yafeng/.git
HEAD branch: master
Remote branch:
    master tracked
    Local ref configured for 'git push':
    master pushes to master (up to date)
software@debian:~/yafeng$ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值