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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM