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

目录

设置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

相关推荐

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

    2024-01-22 07:28:02       37 阅读
  2. git本地仓库远程仓库关联

    2024-01-22 07:28:02       11 阅读
  3. 【GitHub】将本地VueCLI项目关联到GitHub远程仓库

    2024-01-22 07:28:02       11 阅读
  4. git如何配置多个远程仓库,并且进行切换

    2024-01-22 07:28:02       34 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-22 07:28:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-22 07:28:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-22 07:28:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-22 07:28:02       18 阅读

热门阅读

  1. SQL Server 恢复软件

    2024-01-22 07:28:02       32 阅读
  2. PG DBA培训26:PostgreSQL运维诊断与监控分析

    2024-01-22 07:28:02       32 阅读
  3. 第一节 K8S的基础概念

    2024-01-22 07:28:02       32 阅读
  4. 扫雷游戏(c++题解)

    2024-01-22 07:28:02       44 阅读
  5. C++:特殊类的设计和类型转换

    2024-01-22 07:28:02       28 阅读
  6. CAP 角度下的 Redis 与 Zookeeper 锁架构比较

    2024-01-22 07:28:02       34 阅读
  7. pve创建ubuntu cloud虚拟机模版

    2024-01-22 07:28:02       36 阅读
  8. Hive日期函数应用之月份差值计算

    2024-01-22 07:28:02       35 阅读