【问题标题】:! [rejected] master -> master (non-fast-forward) on a new up-to-date branch! [rejected] master -> master (non-fast-forward) 在一个新的最新分支上
【发布时间】:2015-02-28 03:23:49
【问题描述】:

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

【问题讨论】:

    标签: git github git-push git-pull fast-forward


    【解决方案1】:

    检查您的git config push.default。它可能在“matching”上,因为它会尝试推送所有现有的分支。
    那是default before Git 2.0+

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

    话虽如此,要推送一个分支,您需要(对于第一次推送)设置一个 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 工作。

    【讨论】:

      【解决方案2】:

      试试这个:

      希望对你有帮助

      【讨论】:

        猜你喜欢
        • 2013-09-30
        • 2015-04-10
        • 2022-06-13
        • 2011-04-22
        • 2018-04-15
        • 2021-11-23
        • 2018-07-16
        • 2016-04-12
        • 2021-08-01
        相关资源
        最近更新 更多