推送失败(合并返回`已经是最新的`) [英] push failed ( merge returned `already up to date ` )

查看:177
本文介绍了推送失败(合并返回`已经是最新的`)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 develop 分支中所做的更改提取并合并到我的分支 OneUser 中。

/ p>

我在做:

  git checkout OneUser 
git获取原点开发

...
解包对象:100%(21/21),完成。
从https://github.com / .........
*分支开发 - > FETCH_HEAD
e2f ......... d36 develop - >产地/开发

git合并产地开发

已经是最新的。

git commit -a

知道一些变化已经完成了,所以通常它应该给我一些冲突?或者它已经被改变了吗?)

然后,如果我尝试将更改推送到开发:

  git checkout OneUser 
git push -u原点开发

! [rejected]开发 - >开发(非快速转发)
错误:未能将某些参考文献推送到'https://github.com/.../.git
提示:更新被拒绝是因为推送的分支提示是在其远程
背后:对应。检查此分支并在再次推送之前集成远程更改
提示:(例如'git pull ...')。

========= a工作流程========== ==============

  git checkout -b OneUser开发
git分支--set-upstream-to = origin / develop

//从开发分支获取并合并到OneUser
git checkout OneUser
git fetch origin开发
git merge origin / develop

如果您有任何冲突,请解决,添加文件并提交。

//在分支上工作
git添加文件
git commit -m消息

//推送开发
git push origin OneUser:develop


解决方案

希望将本地分支 OneUser 推送到远程分支 develop



在这种情况下,你必须告诉git所以

  git push origin OneUser:develop 

code>

这会告诉git将您的分支(OneUser)存储到源存储库到远程开发分支。



为什么你遇到了错误:

  git checkout OneUser 
git push -u原点开发

! [rejected]开发 - >使用开发(非快进)

git push -u origin开发,您正在指示git:
将名为develop的 local 分支压入与名称匹配的远程分支。既然你已经合并到你的 OneUser 分支,但没有更新你的本地开发分支,git无法推送。您也可以在错误消息中看到它:

 ! [rejected]开发 - >开发(非快进)

更新#1
在你的情况下,你总是希望将你的 OneUser 分支与 develop 同步,在这种情况下,你可以明确要求git对待它,通过发出命令(仅限一次)

  git branch --set-upstream- to = origin / develop 

您可以通过以下方式查看正在跟踪哪个远程分支。

  git status -sb 

然后它只是推动你的本地分支的事情,git会知道在哪里推它。

  git push来源OneUser 


I want to fetch and merge the changes that have been done in develop branch into my branch OneUser.

I am doing:

git checkout OneUser
git fetch origin develop  

...
Unpacking objects: 100% (21/21), done.
From https://github.com/.........
 * branch            develop    -> FETCH_HEAD
   e2f......... d36  develop    -> origin/develop

git merge origin develop

Already up-to-date.

git commit -a

(I know that some changes have been done, so normally it should give me some conflicts?Or what it has been changed? )

Then , if I try to push my changes to develop :

git checkout OneUser
git push -u origin develop

 ! [rejected]        develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://github.com/.../.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.

========= Α workflow ========================

git checkout -b OneUser develop
git branch --set-upstream-to=origin/develop

//fetch from develop branch and merge to OneUser
git checkout OneUser
git fetch origin develop
git merge origin/develop

If you have any conflicts ,solve , add files and commit.

//work on branch
git add "files"
git commit -m "message"

//push to develop
git push origin OneUser:develop

解决方案

If I understand correctly you want to push your local branch OneUser to the remote branch develop

In that case, you will have to tell git so

git push origin OneUser:develop

This tells git to push to origin repository your branch (OneUser) to the develop branch in remote.

Why you faced the error:

git checkout OneUser
git push -u origin develop

 ! [rejected]        develop -> develop (non-fast-forward)

with git push -u origin develop, you were instructing git to: push your local branch named "develop" to the remote branch which matches the name. Since you had merged to your OneUser branch, but not updated your local copy of the develop branch, git failed to push. You can also see it in the error message:

 ! [rejected]        develop -> develop (non-fast-forward)

Update #1 Seems like in your scenario, you would always like to sync your OneUser branch with develop, in that case, you can explicitly ask git to treat it so, by issuing the command (1 time only)

git branch --set-upstream-to=origin/develop

You can check which remote branch is being tracked by:

git status -sb

Then it is simply the matter of pushing your "local" branch, git will know where to push it.

git push origin OneUser

这篇关于推送失败(合并返回`已经是最新的`)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆