英文解決方案鏈接,感謝michaeltwofish,GoZoner,dunnigit
git本地倉庫push遠程倉庫的時候,報了異常:fatal the current branch master has no upstream branchgithub
可是按提示, git push --set-upstream ../remote-jackygit.git master 並無解決問題。翻譯
通過查詢發現目前有兩種解決方案:code
1.翻譯後大體意思是,遠程倉庫建立時候要創建一個README文件,而後再進行push操做。由於這個文件是遠程倉庫主分支所必須的,見以下截圖。ci
Create the repo on github; add a README file on github and then clone the github repository. Creating the README file (or any file actually) is needed in order to get a master branch.Notice how github prompts for creating a README when creating a repository:rem
2.翻譯後大體意思是,若是不想從新建立遠程倉庫再克隆(針對方案1),或者初始化本地倉庫,能夠使用下面命令: git push -u origin master,其中origin 表示遠程倉庫名稱,master是遠程倉庫的push目標分支。-u (推測爲update縮寫^_^~)表示本地分支將創建對遠程倉庫目標分支的檢測,若是遠程倉庫目標分支不存在,將新建分支再push;若是存在,將進行push更新。get
Instead of creating a new repository on Github, cloning that, or reinitializing your local repository, the following command would have been sufficient:it
git push -u origin master
origin stands for the remote name (default is origin), and master is the branch you want to push, in your case it's master, otherwise you would have to change that in the command.
-u means, that your local branch will be setup to track the new created master branch on the origin repository (the master on the origin will be the upstream branch of your local branch). If the branch master doesn't exist on the remote repository, it will be created, otherwise it will be updated (the -u works no matter if it exists or not).io
而後,驗證此方法,確實可行!ast