this post was submitted on 09 Sep 2023
11 points (100.0% liked)

No Stupid Questions (Developer Edition)

934 readers
1 users here now

This is a place where you can ask any programming / topic related to the instance questions you want!

For a more general version of this concept check out [email protected]

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

drawing showing git history made in gimp

So I have a bug fix (green) and owner also made a bug fix (red) but I would like to rework both of them due to discussion we had. I have opened a PR and there is merge conflict that can't be resolved. Should I open a new branch in my fork and close PR or should I google some rebase magic to apply commits to my bug-fix branch.

top 11 comments
sorted by: hot top controversial new old
[–] [email protected] 13 points 1 year ago

If the merge is really too complicated to easily resolve, drop the PR. Then you can pull in latest and make the fix anew. Don't delete your old PR's branch yet, you might want to look up how you did your original fix.

[–] [email protected] 8 points 1 year ago (2 children)

Merge conflicts can always be resolved, just not automatically. You should learn how to resolve them.

[–] [email protected] 2 points 1 year ago

Yep, most merge conflicts that happen on less than 10 lines can be fixed manually. It's an invaluable skill.

[–] [email protected] 2 points 1 year ago (1 children)

The red commit made changes to files that after the merge would produce dead code.

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

Part of doing a merge commit at all is ensuring the merge results in clean code. You would need to resolve this in your merge commit, even if that area of the code was not in a merge conflict. You learn this when learning to resolve merge conflicts.

[–] [email protected] 5 points 1 year ago

I would merge 2.0 into my branch and fix (and test) the conflict there.

[–] [email protected] 3 points 1 year ago

It depends - as with any real answer to a problem. I would likely start with a rebase of you bug-fix on 2.0, resolve any conflicts that might have. If there are multiple commits on bug-fix I might squash them to make the merge easier. But if the conflicts are too complex to really resolve it might be easier and quicker to just redo the work in a new branch if the changes are not that big.

Which was is better for you depends on how big those merge conflicts are. But it seems like a good opportunity to learn how to rebase and how to resolve merge conflicts.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

I'd pull their main, rebase your 2.0 to theirs and then rebase your fix to your 2.0. Then you should have a better view on what has changed between those two. It'll probably result in you cherry picking from your fix.

[–] [email protected] 3 points 1 year ago

Force merge your PR and call out their personal issues in the comments

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

there is merge conflict that can’t be resolved

Why? That's the main question.

Also https://trunkbaseddevelopment.com/branch-for-release/ says that you should:

  1. fix on your branch
  2. PR to master
  3. cherry pick to 2.0

owner also made a bug fix

That's a political issue, not a technical issue. You MUST talk with the owner about it.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Why?

merge resolution would produce more work than opening new PR (couple dozen of lines of code)[I want to learn on small mistakes not on big ones] I would like to rework the owners bug fix to have cleaner code.

Political issue

So I should make a consensus on „Who should make the work?” and „How should feature be implemented?”.

Sadly „2.0” is the trunk and „master” is 1.0 release but thanks for the link