一、本地仓库和远程仓库建立联系
方式一:项目自身带有 .git文件的【自身就是一个本地仓库的】(这里咱以vue-cli3项目为例)
1、创建自带.git本地仓库:创建一个叫 my-vue 的项目

2、创建一个空的远程仓库:github服务器上创建一个叫 my-vue(起个名称+描述一下,其他都不勾选)远程仓库

3、本地仓库和远程仓库建立联系:
3-1、创建完远程仓库有本地仓库提交到远程仓库的指令提示(复制粘贴一下那两条指令):

3-2、报错:
error: src refspec main does not match any
解决:error的大概意思就是没有main这个分支,回去看指令提示:

3-3、又有error:
error setting certificate verify locations: CAfile: D:/git/Git/mingw64/ssl/certs/ca-bundle.crt CApa
解决:输入命令:git config --system http.sslverify false
3-4、又有error:
OpenSSL SSL_read: Connection was reset, errno 10054 或 Failed to connect to github.com port 443 after 21067 ms: Timed out
解决:网络延迟问题,多执行几次即可

3-5、成功建立联系:

方式二:普通项目(这里咱以idea中的java项目为例):
1、先创建一个叫hello-boy的远程仓库(因为本地仓库是要通过克隆方式建立的):

2、克隆远程仓库:


3、成功克隆(即远程和本地仓库已经成功建立联系)

二、提交项目代码到远程仓库进行托管的常用命令:
① git add .
将所有变化的文件添加到本地仓库的缓存区
② git commit '备注信息' 将缓存区的文件提交到本地仓库
③ git push
将本地仓库文件的更新推送到远程仓库