-
解除本地仓库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/*********(远程仓库地址)
将本地其他项目推送到git仓库
最新推荐文章于 2025-11-06 19:38:41 发布
本文详细介绍了如何解除本地git仓库的绑定,重新初始化,并将本地仓库与远程仓库关联。同时,针对git分支不一致的情况,演示了如何修改本地分支名称,并将更改提交到远程仓库。在推送过程中遇到的错误提示,提供了解决方案,包括git pull合并远程仓库的变更。此教程适合git初学者和开发者进行日常版本控制操作。
257

被折叠的 条评论
为什么被折叠?



