5

在我的仓库中,我有一个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

4

2 回答 2

2

检查您的git config push.default. 它可能在“ matching”上,因为它试图推送所有现有的分支。
这是Git 2.0+ 之前的默认设置

我建议将其设置为“ simple”,以便仅推送当前分支。

话虽如此,要推送一个分支,您需要(对于第一次推送)设置一个上游分支

对于以前从未推送过的分支:

git push -u origin newest

对于上游仓库中确实存在的分支:

git branch --set-upstream-to=origin/master master
git branch --set-upstream-to=origin/new new

然后一个git checkout master ; git pull would作品。

于 2015-01-01T13:48:35.447 回答
0

尝试这个 :

希望能帮助到你

于 2015-04-16T15:33:48.650 回答