Git - 推动远程如何修复?

时间:2016-06-07 16:20:17

标签: git

我该怎么做才能解决这个问题?我添加了一个新分支添加的更改,并希望将它们推送到存储库。当我做推动时,我得到了这个消息。当我拉一下它说一切都很好。所以我可以拉,一切都很好,但不是当我推?什么是快进更新?

error: failed to push some refs to '<repository>'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

camdixon@staging2:/var/www/site$ git pull
Username for '<repository>': camdixon
Password for 'username@<repository>': 
Already up-to-date.

1 个答案:

答案 0 :(得分:2)

当您运行git pull时,您正在进行提取,然后进行合并(或提取后跟一个rebase),如What is the difference between 'git pull' and 'git fetch'?中所述。

这合并(或重组)一个分支,即您当前的分支。

请注意之前你的Git打印了这个投诉(我粗言蜚语):

  

error: failed to push some refs to '<repository>' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.

打印哪些引用无法推送,哪些成功。

当您运行git push时,您可能会推送许多引用:例如,您可能会推送17个分支和3个标记,总共20个一次性推送引用。如果你当前的分支是好的,但是其他16个分支都失败了,你通常会看到一个成功和16个失败通知。如果三个标签成功,您将看到这些标签的另外三个成功通知。

如果失败的所有更新对您来说都不是特别有趣,您可以忽略它们。如果你关心的那个人在成功中列出了<或者 ,那么你需要重试。

有关配置默认情况下推送哪些分支的说明,请参阅Default behavior of "git push" without a branch specified"simple" vs "current" push.default in git for decentralized workflow

要推送一个特定分支 ,无论您的默认设置是什么,请在命令行中列出该分支:

git push origin razzle-dazzle-branch

如果这是第一次推送分支,那么这将创建远程存储库中的分支(在此示例中为origin),您可能希望添加{ {1}}标志:

-u

这将告诉您的Git将git push -u origin razzle-dazzle-branch 设置为origin/razzle-dazzle-branch上游,前提是razzle-dazzle-branch成功推送。

  

...什么是快进更新?

查看a google query for git fast forward update site:stackoverflow.com中出现的任何答案,例如What does "Git push non-fast-forward updates were rejected" mean?

相关问题