Live data from Hacker News

Resolve simple merge conflicts on GitHub

github.com

21–30 of 71 posts

Re: Resolve simple merge conflicts on GitHub

#22
post #19
post #4

On my team I've found that it's incredibly useful to commit the merge conflicts and conflict markers, then immediately resolve the conflicts in the next commit. This gives you one commit that shows exactly how the two branches merged together, followed by a commit that shows exactly how the conflicts were resolved. The resolution commit can then be code reviewed independently for a nice clean view of the conflicts in…

You actually can distinguish the new lines. For any non-trivial merge conflict resolution committed as part of the merge, `git show $SHA` will actually show you the conflict resolution. More specifically, if the diff contains anything that's not just a line taken from either of the parents, then that thing is shown.

Yeah, I have no doubt that you can somehow show this information via the command line. The problem is that it's hidden in GitHub's Pull Request web UI, where all of our code review happens. Committing the conflicts and then resolving in the next commit surfaces the conflict resolutions to the PR where it can be reviewed like all of the other code we write.

Re: Resolve simple merge conflicts on GitHub

#23
post #16

Earlier quoted context omitted.

It's literally the hallmark of GitHub... How else would pull requests work? (well, there _is_ the rebase option now...)

Hmm. I usually do merges locally as serious stuff should be built and tested before pushing anyway, so probably why never used GitHub's hosted functions.

If you write tests diligently, you can integrate CI with GitHub. Travis CI might be the most popular option.

Re: Resolve simple merge conflicts on GitHub

#24
post #16

Earlier quoted context omitted.

It's literally the hallmark of GitHub... How else would pull requests work? (well, there _is_ the rebase option now...)

Hmm. I usually do merges locally as serious stuff should be built and tested before pushing anyway, so probably why never used GitHub's hosted functions.

> serious stuff should be built and tested before pushing anyway

Yes and no. Build in your CI server that's set up to mirror your prod environment after pushing, but before merging. That's what the whole industry of CI providers and integrations built into and around GitHub and GitLab is for.

Re: Resolve simple merge conflicts on GitHub

#25
post #22
post #19

Earlier quoted context omitted.

You actually can distinguish the new lines. For any non-trivial merge conflict resolution committed as part of the merge, `git show $SHA` will actually show you the conflict resolution. More specifically, if the diff contains anything that's not just a line taken from either of the parents, then that thing is shown.

Yeah, I have no doubt that you can somehow show this information via the command line. The problem is that it's hidden in GitHub's Pull Request web UI, where all of our code review happens. Committing the conflicts and then resolving in the next commit surfaces the conflict resolutions to the PR where it can be reviewed like all of the other code we write.

The PR UI does this. After resolving conflicts, the resulting merge commit will show just the resolution.

Re: Resolve simple merge conflicts on GitHub

#26
This is the dumbest shit I swear! GIT is super dumb when dealing with conflicts. Maybe GIT needs to get smarter. When another dev, and I work on the exact same line of code. I add a class, and he adds an ID. GIT goes like oh crap a conflict I have zero idea what to do! Here is a bunch of commented crap in your code, and let me tank grunt for you real quick.

Re: Resolve simple merge conflicts on GitHub

#27
post #14

Earlier quoted context omitted.

Great idea! Although this does break cherry-pick, doesn't it?

I'd imagine this also breaks bisect (and might make your CI system very confused), since you have a non-good commit.

Bisect knows how to deal with this; you can tell it to ignore a commit that you know is broken for reasons unrelated to the issue upper investigating (and try adjacent ones instead).

Re: Resolve simple merge conflicts on GitHub

#28
post #5

diff3 conflict style display would be considerably more useful.

Agreed.

It can be a bit noisier at first but once you learn to read it, I find it makes resolving conflicts so much easier.

For those of you who haven't used it, try switching it on and/or read https://psung.blogspot.com.au/2011/02/reducing-merge-headach... for more details.

tl;dr it shows

Re: Resolve simple merge conflicts on GitHub

#29

So simple, so useful, I wonder if this feature wasn't already in Gitlab since it seems to be more full featured

GitLab does have it already: https://docs.gitlab.com/ce/user/project/merge_requests/resol...

That's flipping awesome. Does it already have code review too?
Post reply on HN