一、本地没有仓库时–上传到远程仓库
0、先在github上新建一个仓库
注意:不要选择自动生成readme.md文件
1、https版
cd xx项目
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/username/xxx.git
git push -u origin main
2、git版(即:上传了ssh秘钥)
cd xx项目
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin [email protected]:username/xxx.git
git push -u origin main
二、本地有仓库时–推送并关联到远程仓库
https版
git remote add origin https://github.com/username/xxx.git
git branch -M main
git push -u origin main
git版
git remote add origin [email protected]:username/xxx.git
git branch -M main
git push -u origin main