-
解除本地仓库git的绑定;
rm -rf .git
-
初始化git
git init
-
方便起见如果git仓库的分支与本地分支不一致(比如git分支式main本地master),将本地分支改为main
git branch -m main
-
添加文件到暂存区
git add .
-
暂存区中的内容提交到本地仓库
git commit -m '说明文字'
-
复制git仓库地址并将本地仓库关联自己的远程仓库
git remote add origin 复制的远程git仓库地址
-
推送到远程仓库
git push --set-upstream origin mian
-
报错: error: src refspec mian does not match any
error: failed to push some refs to ‘远程仓库地址’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.git pull origin main --allow-unrelated-histories From https://github.com/*********(远程仓库地址)