简体   繁体   English

git:rebase(合并后)只给出冲突

[英]git: rebase (after merge) gives only conflicts

I have the following situation 我有以下情况

  • created a branch 'dev' 创建了一个分支'dev'
  • worked on 'dev' 在'dev'工作
  • worked on 'master' 致力于'大师'

At some point I want to merge my work from 'dev' into master 在某些时候,我想将我的工作从'dev'合并到master中

$> git checkout master
$> git merge dev

Thats no problem, but now I would like to continue working in branch 'dev'. 这没问题,但现在我想继续在分支'dev'工作。 However, 'master' has some commits which are not yet in 'dev', so I tried to rebase. 但是,'master'有一些尚未进入'dev'的提交,所以我试图改变。

$> git checkout dev
$> git rebase master

This doesn't work and only gives conflicts. 这不起作用,只会产生冲突。 Solving the conflicts doesn't work, because after that there are more conflicts. 解决冲突是行不通的,因为之后会有更多的冲突。 Is there an explanation for this ? 对此有解释吗?

It is a little bit unclear what you want to achieve. 你想要实现的目标有点不清楚。 At the beginning you wrote: 一开始你写道:

At some point I want to merge my work from 'dev' into master 在某些时候,我想将我的工作从'dev'合并到master中

Then you wrote: 然后你写道:

However, 'master' has some commits which are not yet in 'dev', so I tried to rebase. 但是,'master'有一些尚未进入'dev'的提交,所以我试图改变。

If you want to get the work from dev into master you should 如果你想让dev的工作变成master你应该

  1. git checkout master
  2. git rebase dev
  3. solve conflicts if needed 如果需要解决冲突
  4. git rebase --continue

Then you can go back to dev branch with git checkout dev 然后你可以使用git checkout dev返回dev分支

If you want to do it the other way, just switch the names I personally think that running git rebase --continue is the key to your problem. 如果你想以另一种方式做,只需切换名称我个人认为运行git rebase --continue是你问题的关键。

PS: Instead of rebasing, try to consider running a git merge in this case. PS:在这种情况下,尝试考虑运行git merge ,而不是重新定位。

The only reasonable way to get the changes from master back into dev after you have merged dev into master is by merging master into dev, not rebasing dev on top of master. 在将dev合并到master之后, master从master更改回dev的唯一合理方法是 master 合并到dev中,而不是在master上重新设置dev。

Rebasing is usually only used on branches that haven't been merged into anything yet. 重新定位通常仅用于尚未合并到任何内容的分支上。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM