【Git】本地仓库关联远程仓库

Git 本地项目关联远程仓库

本地

本地已有项目

● 项目 07.GitLocalTest 包含有一个js
○ test.js
在这里插入图片描述

远程仓库

● 远程仓库地址
○ https://github.com/Sonnenlicht77/gitTest.git
○ 仓库只有一个 readme.md
在这里插入图片描述

关联

1.本地
1.1 本地仓库

git init
git add .
git commit -m "初始化本地仓库"
在这里插入图片描述

此时,只需将本地仓库和远程仓库连接起来即可。

1.2 连接 远程仓库

git remote add origin https://github.com/Sonnenlicht77/gitTest.git
git pull
○ 此时,会报:

warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/Sonnenlicht77/gitTest
 * [new branch]      main       -> origin/main
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

git branch --set-upstream-to=origin/main : 根据提示,通过 设置分支绑定跟踪

Branch 'master' set up to track remote branch 'main' from 'origin'.

git pull : 显示

fatal: refusing to merge unrelated histories

git fetch origin main :
在这里插入图片描述

git merge --allow-unrelated-histories :
在这里插入图片描述

git push

Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 528 bytes | 176.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To https://github.com/Sonnenlicht77/gitTest.git
   0c1b5c6..6fd9ac8  master -> main

在这里插入图片描述

最后,远程仓库有了 test.js ;本地仓库有了 readme.md 文档
在这里插入图片描述
在这里插入图片描述

相关推荐

  1. git本地仓库远程仓库关联

    2024-03-17 07:08:07       11 阅读
  2. 本地仓库如何与远程仓库进行关联

    2024-03-17 07:08:07       38 阅读
  3. git变更关联远程仓库

    2024-03-17 07:08:07       41 阅读
  4. git fetch 合并远程仓库本地

    2024-03-17 07:08:07       24 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-17 07:08:07       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-17 07:08:07       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-17 07:08:07       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-17 07:08:07       20 阅读

热门阅读

  1. Python网络爬虫内容介绍

    2024-03-17 07:08:07       19 阅读
  2. k8s编排系统

    2024-03-17 07:08:07       18 阅读
  3. Github Gitlab SSH 密钥配置

    2024-03-17 07:08:07       19 阅读
  4. Elasticsearch快速检索的法宝: 倒排索引

    2024-03-17 07:08:07       22 阅读
  5. 数据挖掘与大数据的结合

    2024-03-17 07:08:07       19 阅读
  6. 记录一次业务遇到的sql问题

    2024-03-17 07:08:07       16 阅读
  7. 获取ArcGISPro中conda信息详情

    2024-03-17 07:08:07       19 阅读
  8. 指定函数为内置函数——个人练习

    2024-03-17 07:08:07       17 阅读
  9. unity-unity2d tilemap的基本使用笔记0.5.4000

    2024-03-17 07:08:07       17 阅读
  10. 七大排序(简洁思路版)

    2024-03-17 07:08:07       21 阅读