将文件夹初始化成本地仓库:git init
代码添加: git add .
查看远程仓库 :git remote -v
提交:git commit -m "first commit"
git remote add origin git@github com:leiphp/awesome-python3-webapp.git
推送远程仓库:git push [remoteName] [localBranchName]
比如:git push origin_ssh main
报错:hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法:
git init //初始化仓库
-
git add .(文件name) //添加文件到本地仓库
-
git commit -m “first commit” //添加文件描述信息
-
git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
-
git pull origin master // 把本地仓库的变化连接到远程仓库主分支
-
git push -u origin master //把本地仓库的文件推送到远程仓库
如果确保本地没问题的话,可以直接用git push -f强行上传
如果还是出错可以把git pull origin master换成git pull --rebase origin master,就把远程仓库的文件同步到本地,本地就多了readme文件了,就可以上传了