1.0 如何关联
要将远程仓库与本地仓库关联起来,您可以使用 git remote add
命令。具体来说,这个命令的基本格式如下:
cpp
git remote add <远程仓库名称> <远程仓库的URL>
这里 <远程仓库名称> 通常默认为 origin,但您也可以根据需要指定其他名称。<远程仓库的URL> 是远程仓库的地址,可以是 HTTPS 形式,也可以是 SSH 形式,取决于您的仓库设置。
例如,如果您想将一个名为 origin 的远程仓库添加到您的本地项目中,且该远程仓库的 URL 是 https://github.com/username/repository.git,则应执行以下命令:
cpp
git remote add origin https://github.com/username/repository.git
这样就将您的本地仓库与指定的远程仓库关联起来了。之后,您可以使用诸如 git fetch、git pull 和 git push 等命令与远程仓库进行交互。如果想要查看当前配置的所有远程仓库,可以使用 git remote -v 命令。
2.0 实际操作
git init 初始化本地厂库


关联本地仓库到远程

推送本地仓库
git add . 添加文件到暂存区
git commit -m "xxxxxx" 添加文件到本地仓库
git pull 同步一下远程仓库
git push origin【ProjectName】 master 推送本地文件到远程仓库
cpp
huangtao@DESKTOP-L13FO4Q MINGW64 /f/ProjectManager/00_AirWarGame (master)
$ git push AirWarGame master
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 8 threads
Compressing objects: 100% (12/12), done.
Writing objects: 100% (16/16), 3.70 KiB | 757.00 KiB/s, done.
Total 16 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag a143f492
To https://gitee.com/etf-et/air-war-game.git
* [new branch] master -> master
huangtao@DESKTOP-L13FO4Q MINGW64 /f/ProjectManager/00_AirWarGame (master)
$

