【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

○ 此时,会报:

bash 复制代码
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 : 根据提示,通过 设置分支绑定跟踪

bash 复制代码
Branch 'master' set up to track remote branch 'main' from 'origin'.

● git pull : 显示

bash 复制代码
fatal: refusing to merge unrelated histories

● git fetch origin main :

● git merge --allow-unrelated-histories :

● git push

bash 复制代码
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 文档

相关推荐
默_笙19 分钟前
🌊 向量库和 ES 都查不出"关系",我只好给奶茶建了一张人脉网
前端·javascript
优选资讯31 分钟前
标签打印软件怎么对接 Excel 数据
前端·excel
一个风轻云淡1 小时前
GCC 和 GDB命令简单解读
java·linux·前端
u0111026752 小时前
图片处理接口如何统一错误信息 前端提示与后端错误码设计
前端·状态模式
福兮说3 小时前
浏览器里把 iPhone 的 HEIC 转成 JPG:Chrome 解不开、转完大了七成、拍摄时间全丢,六个坑实测
前端·javascript·图像处理·chrome·ios·iphone·heic
libokaifa3 小时前
把语音模型塞进手机:sherpa-onnx 在 Android 上的 ASR / TTS
前端
deli0073 小时前
DLA 枝晶生长实测:5000 个粒子集体停摆之后,分形维数收敛到 1.70
前端
小小小米粒3 小时前
重置本地git
大数据·git·elasticsearch
IT_陈寒3 小时前
Redis卡顿的锅,这次真不是大key的错
前端·人工智能·后端
可乐鸡翅yeah_4 小时前
video.js 集成 hls.js 开发 M3U8 播放器,新手高频踩坑
开发语言·前端·javascript·后端·ecmascript·m3u8·音视频在线播放