PyCharm git tool: rebase
Maybe this is more of a git question, but the issue is related to the resolve conflict screen when merging or rebasing.
I have a main branch and several other branches to develop features. These features are merged into the main branch as they are completed, and also the main branch has development of its own. As any of these feature branches are worked, I also want to keep them up to date with the main branch, so I want to apply any change made in the main branch to the feature branch as well. I read that the proper way of doing this is with rebasing rather than merging.
So I made a couple of commits in the main branch and then switched to the feature branch and tried rebasing scheduler onto it. And here is the issue: Instead of transparently accepting the changes (as would happen if I had used merge instad), I am getting loads of resolve conflict screens and it feels like I need to review commits I made way in the past.
So what am I doing wrong? How can I just update the feature branch with the changes made to main branch and resolve conflicts just once, as if I was merging?
请先登录再写评论。
Rebase is useful if you want to keep the history straight. For example, if you want to fully merge the feature branch into master, it is worth rebasing the feature branch onto master before merging, so that fast-forward merge can be used.
Rebase replays ALL commits from the branch you rebase to the branch you rebase onto. If commit is already contained in the target branch, it is skipped, if not - applied on top of the current head. So if branches diverged long ago, it will go from all old commits as well, and you have to resolve conflicts if they appear with old commits.
To get changes from master to the feature branch you could cherry-pick commits if there are few of them. Or just merge.
See https://git-scm.com/book/en/v2/Git-Branching-Rebasing