英文解决方案链接,感谢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