在我的回购中,我有一个master
分支和一个new
分支。
我已经在new
工作了一段时间,做了提交,然后按我的方式推进。我现在决定分支new
并将其称为newest
。所以我做了
git checkout -b "newest"
并且分支已成功创建。我添加了一个文件,并开始研究它。我做了几次改变。
但是当我尝试将这个新分支和我的更改推送到origin
时,我收到此错误:
C:\wamp\www\myproj>git push origin
To https://github.com/Imray/Proj.git
! [rejected] master -> master (non-fast-forward)
! [rejected] new -> new (non-fast-forward)
error: failed to push some refs to 'https://github.com/Imray/Proj.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
所以,正如说明书中所指出的那样,我尝试了git pull
,但后来我得到了:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> newest
我被困住了。
如何将新分支和更改推送到github
?
答案 0 :(得分:2)
检查git config push.default
。它可能在&#34; matching
&#34;,因为它试图推送所有现有的分支
那是default before Git 2.0+。
我建议将其设置为&#34; simple
&#34;,以便仅推送当前分支。
话虽这么说,要推动分支机构,您需要(第一次推送)设置 upstream branch 。
对于之前从未推过的分支:
git push -u origin newest
对于upstream repo上存在的分支:
git branch --set-upstream-to=origin/master master
git branch --set-upstream-to=origin/new new
然后git checkout master ; git pull would
工作。
答案 1 :(得分:0)