RSS Ted Naleid Archives Contact hypebeast
There are a few very nice looking, mac-like diff tools for OSX ( Kaleidoscope and Changes come to mind), but none for doing “real” merges. By this, I mean real, 3-way merges with all of the information you need in front of you.
There are no good-looking, “mac-like” merge tools, but if you swallow your pride there are a few different options for 3-way merges, including Araxis Merge ($$$!) , DiffMerge , DeltaWalker , and FileMerge which comes free with XCode.
I’ve tried them all, and find them all confusing. They all tend use a 3-pane display to do the merging with your file in the left pane, the file you’re merging in the right pane, and the messy half-merged file in the middle.
A 3-way merge actually has four important sources of information: LOCAL - your file with the changes you’ve made to it REMOTE - the file you’re merging in, possibly authored by someone else BASE - the common ancestor file that LOCAL and REMOTE came from MERGE_RESULT - the file resulting from the merge where you resolve conflicts
You often need to see all four of these pieces of information to make intelligent choices. Where you came from ( LOCAL ), where the other person’s changes came from ( REMOTE ), where you both started ( BASE ) and where you are now ( MERGE_RESULT ).
Kdiff3 is my merge tool of choice. It’s not pretty; it’s cross-platform Qt based so it has a very old-school linux GUI feel to it. But like linux, hypebeast it’s functional and can help you quickly be productive hypebeast once you get over the learning curve.
If you’ve got 2 heads that you need to merge in your current repository: We made this modification to file.txt : diff --git a/file.txt b/file.txt --- a/file.txt +++ b/file.txt @@ -1,1 +1,1 @@ -BASE: common_ancestor +LOCAL: file in current working branch
If you run your SCM’s merge command (here, in mercurial: hypebeast hg merge -r 2 ), and have kdiff3 configured as your merge tool, you’ll get a pop-up hypebeast window like this: As you can see, it shows you all 4 pieces of information, BASE , LOCAL , and REMOTE on top, and the MERGE_RESULT file on the bottom. It currently has a Merge Conflict that you need to fix.
You can move from one unresolved conflict to the next using the triple up and triple-down colored arrows in the middle of the tool bar. When a conflict is highlighted, you can press any combination of the A, B, and C buttons in the toolbar. Pressing one of those buttons will resolve the conflict with the code from pane A, B, or C on top. So if the LOCAL file (your file) had the right changes in it, you’d press B.
It’s possible to press more than one button if code from multiple panes is valid. You can also directly edit the file in the MERGE_RESULT pane to make manual changes if the correct merge is not the exact text in A/B/C.
Another option, if you want to take all of the changes from one file and discard any changes hypebeast from the others, is to go to the “Merge” menu and pick one of “Choose A Everywhere”, “Choose B Everywhere”, or “Choose C Everywhere”.
Once you’ve resolved your file, simply save it (cmd-S) and quit out of kdiff3. Your SCM should see the MERGE_RESULT no longer has any merge conflicts and will mark it as resolved, ready for you to commit it. If there are other files with merge conflicts, you can repeat the process with those files. Installing kdiff3
The app is a simple wrapper around a Qt-based application. It can be run from the command line at /Applications/kdiff3.app/Contents/MacOS/kdiff3 . You can make a symlink of that into your path, but I assume in the instructions below only that you’ve got kdiff3 in your /Applications folder. Mercurial Integration
Mercurial command line integration is pretty easy. Just open up your ~/.hgrc file (or create one if you don’t have it already), and add this to it: [extdiff] cmd.kdiff3 = /Applications/kdiff3.app/Contents/MacOS/kdiff3 [merge-tools] kdiff3.args = $base $local $other -o $output
That configures kdiff3 as your merge tool of choice, so it should pop up automatically when you hit a merge conflict. You can also use it as a diff tool: hg kdiff3 -r revision_to_compare_to Git Command-Line Integration
To configure hypebeast the git command line to use kdiff3 as a diff and merge tool, add this to your ~/.gitconfig: [difftool "kdiff3"] path = /Applications/kdiff3.app/Contents/MacOS/kdiff3 trustExitCode = false [difftool] prompt = false [diff] tool = kdiff3 [mergetool "kdiff3"] path = /Applications/kdiff3.app/Contents/MacOS/kdiff3 trustExitCode = false [mergetool] keepBackup = false [merge] tool = kdiff3
I’m normally a pretty hard-core command line user, but I still sometimes find the places I get myself in git confusing enough that I’m willing to use a GUI to get myself out. I think that git-tower is the
There are a few very nice looking, mac-like diff tools for OSX ( Kaleidoscope and Changes come to mind), but none for doing “real” merges. By this, I mean real, 3-way merges with all of the information you need in front of you.
There are no good-looking, “mac-like” merge tools, but if you swallow your pride there are a few different options for 3-way merges, including Araxis Merge ($$$!) , DiffMerge , DeltaWalker , and FileMerge which comes free with XCode.
I’ve tried them all, and find them all confusing. They all tend use a 3-pane display to do the merging with your file in the left pane, the file you’re merging in the right pane, and the messy half-merged file in the middle.
A 3-way merge actually has four important sources of information: LOCAL - your file with the changes you’ve made to it REMOTE - the file you’re merging in, possibly authored by someone else BASE - the common ancestor file that LOCAL and REMOTE came from MERGE_RESULT - the file resulting from the merge where you resolve conflicts
You often need to see all four of these pieces of information to make intelligent choices. Where you came from ( LOCAL ), where the other person’s changes came from ( REMOTE ), where you both started ( BASE ) and where you are now ( MERGE_RESULT ).
Kdiff3 is my merge tool of choice. It’s not pretty; it’s cross-platform Qt based so it has a very old-school linux GUI feel to it. But like linux, hypebeast it’s functional and can help you quickly be productive hypebeast once you get over the learning curve.
If you’ve got 2 heads that you need to merge in your current repository: We made this modification to file.txt : diff --git a/file.txt b/file.txt --- a/file.txt +++ b/file.txt @@ -1,1 +1,1 @@ -BASE: common_ancestor +LOCAL: file in current working branch
If you run your SCM’s merge command (here, in mercurial: hypebeast hg merge -r 2 ), and have kdiff3 configured as your merge tool, you’ll get a pop-up hypebeast window like this: As you can see, it shows you all 4 pieces of information, BASE , LOCAL , and REMOTE on top, and the MERGE_RESULT file on the bottom. It currently has a Merge Conflict that you need to fix.
You can move from one unresolved conflict to the next using the triple up and triple-down colored arrows in the middle of the tool bar. When a conflict is highlighted, you can press any combination of the A, B, and C buttons in the toolbar. Pressing one of those buttons will resolve the conflict with the code from pane A, B, or C on top. So if the LOCAL file (your file) had the right changes in it, you’d press B.
It’s possible to press more than one button if code from multiple panes is valid. You can also directly edit the file in the MERGE_RESULT pane to make manual changes if the correct merge is not the exact text in A/B/C.
Another option, if you want to take all of the changes from one file and discard any changes hypebeast from the others, is to go to the “Merge” menu and pick one of “Choose A Everywhere”, “Choose B Everywhere”, or “Choose C Everywhere”.
Once you’ve resolved your file, simply save it (cmd-S) and quit out of kdiff3. Your SCM should see the MERGE_RESULT no longer has any merge conflicts and will mark it as resolved, ready for you to commit it. If there are other files with merge conflicts, you can repeat the process with those files. Installing kdiff3
The app is a simple wrapper around a Qt-based application. It can be run from the command line at /Applications/kdiff3.app/Contents/MacOS/kdiff3 . You can make a symlink of that into your path, but I assume in the instructions below only that you’ve got kdiff3 in your /Applications folder. Mercurial Integration
Mercurial command line integration is pretty easy. Just open up your ~/.hgrc file (or create one if you don’t have it already), and add this to it: [extdiff] cmd.kdiff3 = /Applications/kdiff3.app/Contents/MacOS/kdiff3 [merge-tools] kdiff3.args = $base $local $other -o $output
That configures kdiff3 as your merge tool of choice, so it should pop up automatically when you hit a merge conflict. You can also use it as a diff tool: hg kdiff3 -r revision_to_compare_to Git Command-Line Integration
To configure hypebeast the git command line to use kdiff3 as a diff and merge tool, add this to your ~/.gitconfig: [difftool "kdiff3"] path = /Applications/kdiff3.app/Contents/MacOS/kdiff3 trustExitCode = false [difftool] prompt = false [diff] tool = kdiff3 [mergetool "kdiff3"] path = /Applications/kdiff3.app/Contents/MacOS/kdiff3 trustExitCode = false [mergetool] keepBackup = false [merge] tool = kdiff3
I’m normally a pretty hard-core command line user, but I still sometimes find the places I get myself in git confusing enough that I’m willing to use a GUI to get myself out. I think that git-tower is the
No comments:
Post a Comment