本地仓库如何与远程仓库进行关联

目录

设置Git 全局设置:

创建一个远程仓库

创建本地仓库

连接远程仓库

查看远程仓库origin的关联信息

查看所有远程仓库

切换远程仓库


设置Git 全局设置:
git config --global user.name "your name"
git config --global user.email "your email@163.com"
创建一个远程仓库

在远程的github、gitee公有仓库平台或是自己的私有git服务里创建一个仓库,如swy-stock

以gitee为例:创建你的第一个仓库 - Gitee.com

创建本地仓库

创建 git 仓库:

mkdir swy-stock
cd swy-stock
git init 
touch README.md
git add README.md
git commit -m "first commit"

已有仓库?

cd swy-stock
连接远程仓库
git remote add origin https://gitee.com/swy/swy-stock.git
git push -u origin "master"
查看远程仓库origin的关联信息
git remote show origin
* remote origin
  Fetch URL: https://gitee.com/swy/swy-stock.git
  Push  URL: https://gitee.com/swy/swy-stock.git
  HEAD branch: master
  Remote branches:
    master              tracked
查看所有远程仓库
git remote -v
origin  https://gitee.com/swy/swy-stock.git (fetch)
origin  https://gitee.com/swy/swy-stock.git (push)
origin2  https://github.com/swy/swy-stock.git (fetch)
origin2  https://github.com/swy/swy-stock.git (push)
切换远程仓库

比如切换到origin2

git fetch origin2
  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值