记录

执行 git status 发现提示:

On branch main
Your branch is up to date with 'origin/main'.

直接 git add .git commit -m "修改"git push origin main,发现无法提交。

于是搜索,根据这篇文章: git commit提示Your branch is up-to-date with 'origin/master'.,认为是版本分支的原因(不大懂)。

新建分支

git branch newbranch
//查看是否是否创建成功
git branch 
//若结果中有 newbranch,即成功

切换新分支并提交改动

git checkout newbranch
git add . 
git commit -m "改动"

切换主分支并合并改动

git checkout master
git merge newbranch 

提交代码

git push -u origin master

删除新分支

git branch -D newbranch

后记

完成上述流程后,已能提交代码,但是仍会提示:

On branch main
Your branch is up to date with 'origin/main'.

根据此文,暂不理会。

Q.E.D.

本文由 ruchan 创作,如果您觉得本文不错,请随意赞赏
采用 知识共享署名4.0 国际许可协议进行许可,转载前请务必署名
本文链接:https://crcrc.cn/archives/git-push-problems
最后更新于:2021-08-29 09:14:24


Not afraid of the future, not thinking of the past.