7 ms·
On a related note, I seriously recommend everyone to set their merge.conflictStyle to diff3 (or even zdiff3 on newer Gits). It shows you all of your version, t
by ainar-g 4y ago
On a related note, I seriously recommend everyone to set their merge.conflictStyle to diff3 (or even zdiff3 on newer Gits). It shows you all of your version, thier version, and the original, common-ancestor version. It really should be the default, and, as far as I know, the only reason it isn't is because there are some older diff(1) implementation that don't support three-way diffs.
See https://blog.nilbus.com/take-the-pain-out-of-git-conflict-resolution-use-diff3/ https://blog.nilbus.com/take-the-pain-out-of-git-conflict-re... and https://stackoverflow.com/q/27417656 https://stackoverflow.com/q/27417656.
- glogla 4y agoHow can this be a thing since 2008 and I didn't know? Thank you!
- NeckBeardPrince 4y agoI just learned about push-options last week. https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt https://git-scm.com/docs/git-push#Documentation/git-push.txt... https://docs.gitlab.com/ee/user/project/push_options.html https://docs.gitlab.com/ee/user/project/push_options.html
- hiq 4y agoWhat do you use them for? I went through the GitLab doc, I see how it could make sense for automated PRs, but for manual ones I don't see how I would benefit from them.
- tenken 4y agoDebugging a deploy job (stage) from a feature branch via an env variable.
- mdaniel 4y agoPlease vote for the resulting issues from that thread in order to help others discover the feature: https://news.ycombinator.com/item?id=31040637 https://news.ycombinator.com/item?id=31040637
- _ZeD_ 4y agoApart from the "Ten Thousand" xkcd reference, I heavely suggest to use the venerable kdiff3[1] [1] http://kdiff3.sourceforge.net/ http://kdiff3.sourceforge.net/
- encryptluks2 4y agoEven better may be to install and use git-delta which does this amongst many other things: https://github.com/dandavison/delta https://github.com/dandavison/delta
- lilyball 4y agoThe parent comment is about merge style, not diff style. Delta displays diffs, it's not a merge tool.
- encryptluks2 4y agoIt is also a tool to resolve merges as well.
- lilyball 4y agoIt can display merge conflicts (as Git can display those) but it doesn't resolve them. It's purely a display tool. Its installation instructions recommend setting `merge.conflictstyle = diff3` but that's not an automatic process.
- aendruk 4y agoHow so? Its documentation on merge conflicts just reiterates setting `diff3`.
- tylerFowler 4y agoI think learning diff3 has had one of the largest ROIs of anything I've perhaps _ever_ learned. I show it to interns whenever I can, which tends to remind me just how daunting it is to use for the first time.
- lazulicurio 4y agoIs there a way to change the output format? I find that "||||||| merged common ancestor" to be very noisy, visually.
- kazinator 4y agoRelevant: https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts https://www.gnu.org/software/diffutils/manual/diffutils.html... When I'm merging, and things are really messed up due to unrelated things being diffed together, in a situation in which both must survive in the merged result, I do this: 1. Find syntactic boundaries before and after the conflict, in order to delimit an area that is a complete piece of top-level syntax, in which the conflict lies. So that is to say if the conflict is flanked by fragments of syntax, I include them. 2. I make a copy of this entire area, so that I have two consecutive copies of the complete syntactic unit, and therefore two copies of the conflict. 3. Go through the first copy and edit it with a view toward one side of the conflict. 4. Repeat on the second copy, but with a view toward keeping the changes from the other side of the conflict. Example (manually created): static void foo(int x) { <<<<<<< return x; } static void bar(int y) { return y; ======= return x + 1; } static void xyzzy(int z) { return z >>>>>>> } WTF? Ah, OK: there is originally a foo(), and one side added bar() and the other xyzzy(). We need both. Ah, and foo was tweaked t o be different. OK, what is the complete syntactic unit? We include everything from the "static void foo" to the closing brace after the >>>>>> and copy it. We include markers: // COPY A static void foo(int x) { <<<<<<< return x; } static void bar(int y) { return y; ======= return x + 1; } static void xyzzy(int z) { return z >>>>>>> } // COPY B static void foo(int x) { <<<<<<< return x; } static void bar(int y) { return y; ======= return x; } static void xyzzy(int z) { return z >>>>>>> } Now we work through COPY A, keeping the <<<<<<< side: // COPY A static void foo(int x) { return x; } static void bar(int y) { return y; } // COPY B static void foo(int x) { <<<<<<< return x + 1; } static void bar(int y) { return y; ======= return x; } static void xyzzy(int z) { return z >>>>>>> } Then through COPY B, keeping the >>>>>>> side: // COPY A static void foo(int x) { return x; } static void bar(int y) { return y; } // COPY B static void foo(int x) { return x + 1; } static void xyzzy(int z) { return z } Now get rid of the duplicate foo. It looks like we need the one which does "return x + 1": static void foo(int x) { return x + 1; } static void bar(int y) { return y; } static void xyzzy(int z) { return z }
- karmakaze 4y agoIf I didn't use JetBrains' products for anything else, I'd still use it for git -> Resolve Conflicts.
- user3939382 4y agoAmen. I also have Kaleidoscope which is great for diffs but nothing beats Resolve Conflicts from JetBrains.
- Too 4y agoYou can also just type “git mergetool” and it will open up your difftool of choice with all 4 versions of the file on one screen. Assuming you have a difftool capable of 3-way merge. Manually reading through merge conflict markers feels very old once you get used to this.