简体   繁体   English

在将master合并到我自己的分支时获取合并提交

[英]Getting merge commit while merging master to my own branch

I am trying to merge master to my feature branch derived from master. 我正在尝试将master合并到派生自master的功能分支中。 Master branch is already ahead by N commits. Master分支已经提前N次提交。 so to merge i gave following commands after checking out my branch B1 所以要合并,我在签出我的分支B1后给出了以下命令

1) git pull
2) git merge master

Both worked well, but now when i gave command: 两者都运行良好,但是现在当我发出命令时:

git push origin B1

i was getting error: 我收到错误消息:

Found Merge commit in refs/heads/B1, not pushing error: failed to push some refs to git@git.corp.company.com:ProjectName/bullseye.git 在refs / heads / B1中发现合并提交,未推送错误:无法将某些引用推送到git@git.corp.company.com:ProjectName / bullseye.git

Any idea how to merge master to my branch remotely. 任何想法如何将master远程合并到我的分支。

use git pull origin --rebase master instead. 使用git pull origin --rebase master代替。

But use git reflog to see where your branch was before you did git pull . 但是,在执行git pull之前,请使用git reflog查看分支的位置。 After you find the sha-1, git reset sha-1 --hard and then run the --rebase pull. 找到sha-1之后, git reset sha-1 --hard ,然后运行--rebase pull。

Judging from the error message your remote seems to dislike merges in non- master branches. 从错误消息来看,您的遥控器似乎不喜欢非master分支中的合并。 What you should do then is rebase onto master instead. 然后,您应该做的是将基础改master

git checkout B1
git fetch origin
git rebase origin/master

Usually, rebase should also undo all merges you already did. 通常, rebase还应该撤消您已经完成的所有合并。 In case it doesn't you can undo the rebase 如果没有,您可以撤消变基

git reset --hard <sha1 of B1 before rebase>

and then find the commit right before the merge and reset to it: 然后在合并之前找到提交并重置为:

git log
git reset --hard <sha1 of commit before merge>

afterwards you can rebase again. 之后,您可以重新设置rebase Also git reflog is handy to keep an overview of the different states you go through while merging and rebasing. git reflog还可方便地概述合并和重新定基时所经历的不同状态。

What you cannot do is "merge branches remotely". 您不能做的是“远程合并分支”。 Git does not allow that. Git不允许这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git 多个合并分支-合并到主分支时如何避免多次提交 - Git multiple merge branches- how to avoid multiple commit while merging to master branch 如何安排从master分支到我的功能分支的合并,并在我的功能分支上提交自己的工作? - How shall I arrange merge from the master branch into my feature branch and commit of my own work on my feature branch? 使用git将主分支合并到开发分支时出错 - Getting error while merging master branch into development branch using git 主提交然后与另一个分支合并 - Master commit then merge with another branch 将1个分支的1个提交合并到主服务器? - merge 1 commit from 1 branch to the master? Git:将本地主人合并到我自己的测试分支中 - Git: Merge local master into my own test branch 将master与第二分支合并并提交给master - Merge master with 2nd branch and commit to master 将分支加入新的主提交而不合并? - Join branch into new master commit without merging? 如何使先前的提交成为主分支的负责人,同时忽略从最近合并到主分支的所有内容? - How to make a previous commit the head of the master branch while ignoring everything from the most recent merge into master? Git merge master进入开发分支是覆盖,而不是合并 - Git merge master into development branch is overwriting, not merging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM