1

When on feature branch I use git rebase master, then a lot code is replaced automatically with code from master, and I get only one merge conflict. But those branches differ a lot, and I would expect more conflicts. Also files created before on feature (which does not exist on master) are removed.

Is there a way to look into all these changes, compare them and choose the ones I need. And only then finish rebasing.

andriejka
  • 17
  • 1
  • 5
  • You mean like interactive merge conflicts solving? Some IDE has very nice UI for that (e.g. PHPStorm https://www.jetbrains.com/help/phpstorm/resolving-conflicts.html#distributed-version-control-systems) – Justinas Nov 16 '21 at 11:27
  • If you want to only chose specific changeset, rebase is the wrong tool. You may be interested in [git cherry pick](https://git-scm.com/docs/git-cherry-pick) instead. – k0pernikus Nov 16 '21 at 11:37

1 Answers1

3

The files are not missing. Your rebase hasn't reached the point yet to apply those files. You only see one merge conflict now, once that it resolved and you continue, more may pop up.

As in the context of a rebase, you start from the head of the source branch, and all the commits of your target branch are applied one by one on it.

If a merge conflict arises, rebase stops to ask you to resolve the merge conflict. You have to fix them as they come one by one, and then continue the rebase each time a conflict occurs by marking the afflicted files as solved via:

git add <resolved file>

and then running:

git rebase --continue

until all the conflicts are resolved.

In a best case scenario all the changes are applied without any conflicts.

If in doubt, you can always hit

git rebase --abort

to get back to your feature branch as it was before you started the rebase.

There's not a real way to look at your changes as one during a rebase. You can do that beforehand

git diff <branchname>

If a rebase gets overly complicated, I like to use git merge as then you see all the changes (and conflicts) at once as you may expect. That might be easier to resolve for you.

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
  • 1
    Thanks, it worked. I didnt realize that git rebase --continue goes into next commit and that was the reason, I thought I should get all at once, for some reason... – andriejka Nov 16 '21 at 21:07
  • @andriejka If that solved your question, please feel free to mark the answer as accepted. That's the stackoverflow way of saying thank you :) https://stackoverflow.com/help/someone-answers https://stackoverflow.com/help/accepted-answer – k0pernikus Nov 17 '21 at 09:20
  • 1
    I wasnt aware of this, just did it, thanks – andriejka Nov 18 '21 at 09:23