生成的public文件夹 git status时发现仓库丢了,也就是.git文件夹被干掉了。
- git init
- git status
- git add .
- git commit -m “标记内容”
- git remote add origin https://github.com/rousongs/zrs.github.io.git
- git push -u origin main 报错 error: src refspec main does not match any 可能是本地仓库名字叫master而github上叫main吧
- git branch -M main
- git push -u origin main 报错 ! [rejected]
- git push -f origin main 强制推送
如果在线有修改文件,git push 可能也会报rejected,此时先git pull一下,再git push
如果pull时提示本地文件有修改"error: Your local changes to the following files would be overwritten by merge. “,丢弃本地文件改动,强制把远程仓库pull下来:
# 1. 拉取远程仓库的最新信息(不自动合并)
git fetch origin
# 2. 强制将本地分支重置到远程分支的状态(以 main 分支为例)
git reset --hard origin/main
# 若你的分支名是 master,则替换为:
# git reset --hard origin/master