git push本地master分支到远程github的main分支

git push本地master分支到远程github的main分支

最简单的方式是保持本地和远程的分支同名,当然这样也不算解决问题

拉取远程的main分支到本地master分支

首先要从远程的main分支中拉取一次

git pull origin main

这里如果本地的分支不为空的话,需要进行merge

push 到远程

直接

git push origin main

会报错

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

尝试按照提示的输入也还是没有作用

最后指定本地和远程的分支解决问题

git push origin master:main
posted @ 2021-11-23 18:16  wonder32  阅读(1211)  评论(0)    收藏  举报