How to link external diff tool(beyond compare) in source tree? - atlassian-sourcetree

I am using Source tree client for Git on windows 7. I have used beyond compare with tortoisehg client for mercurial and I like to use Beyond compare itself as diff too in SourceTree too. I set the diff tool to beyond compare in Tools -> Options but not sure how to launch diff too via source tree for any file. Double click on file should usually bring up diff view. Right-click -> Custom action also does nothing.
Beyond compare 3.3.13 & source tree 2.1.2.5
Please let me know how to configure this.

It works for me:
After the installation, check whether you have set this in SourceTree options:
Right click on the file(s) you want to compare and fire up Beyond Compare:
Beyond Compare 4.2.2 & SourceTree 2.1.2.5
Also please make sure your Beyond Compare trial period has not ended

In addition of the file compare/merge, I use the sourcetree custom actions in order to compare two commits as folder comparison.
Assuming git & beyond compare in the PATH, you can add this following custom action in Sourcetree (Tools > Option > Custom Actions):
Script: git
Parameters: difftool -d --tool=bc4 $SHA
Tested with Sourcetree 3.4.8, git 2.35, beyond compare 4.4.2

The following worked for me in few easy steps:
Configured git to use beyond control as the diff and merge tools as per official documentation.
https://www.scootersoftware.com/support.php?zz=kb_vcs#gitwindows
Setup sourcetree custom command enabling diff using Beyond compare by selecting two commits similar to TortoiseHG.
SourceTree->Tools->Options->Custom Actions
Script to run: git
Parameters: difftool --dir-diff $SHA

Related

VS Code style and appearance for git diff (side by side) [duplicate]

I would like to know how to see as a file with the command git diff master origin/master in the terminal on Visual Studio Code.
I did a git fetch from my remote repository, and now I want to see the diff, but with the command just show me in the terminal.
Example of what I want:
In Visual Studio Code, on the left side, there is a Git icon that looks like this:
By clicking on this icon, then double-clicking one of the files listed under Changes you can see the Git difference in two sides.
If you want to see the diff changes from different branches, there is some extra work. For example you want to see all the changes from last N commits in your Feature branch.
Set up Visual Studio Code to be your default difftool by adding this in your ~/.gitconfig file.
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
Go to your Git project. Type in:
git difftool {{branch you want to check with}}, for example git difftool master
You will be prompted for each file, if you want to open it in Visual Studio Code or not.
You can achieve this in Visual Studio Code by
Opening up settings (On window/linux File > Preferences > Setting.
On macOS Code > Preferences > Settings)
Search for diff
The specific setting is Diff Editor:Render Side by Side. Mark the checkbox.
After hours of searching, installing and uninstalling extensions, it seems this is already implemented in VSC.
Just click on the top right icon - "Open changes"
And go back to seeing only the file, not the changes, by clicking on the... top right icon - "Open file"
If you want to compare between two arbitrary references - for example comparing between branch and branch, or a commit and another commit - and still view all files in one shot easily just like we see the index changes.
Install the GitLens extension
Go to the Source control in the left pane.
If you don't have the icon then you can look under menu View -> SCM (Show source control) or use the defined shortcut.
Expand the last section Search & Compare
Click on button Compare References...
Pick the references, and then you will see the list of changed files and clicking one file will show its changes side to side.
I have answered a similar question here.
But basically you can use the following command:
git difftool -x "code --wait --diff"
Open file ~/.gitconfig in Visual Studio Code:
code ~/.gitconfig
Copy the following lines in ~/.gitconfig:
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
Save the changes. Open a terminal in Visual Studio Code by running Ctrl + Shift + `. Run the following command in the terminal:
git difftool master origin/master
Here's a simple way to view your changes since last commit (on current branch):
Click Git icon on left side of VS Code
If you've made changes to the file(s) since last commit, you'll see the file(s) listed under "CHANGES"
Right click the file name (under "CHANGES") and click "Open Changes"
This will open the two versions of the file side by side with the changes highlighted
toggle inline view now is available (on the 3 dots)
You can diff any two files by first right clicking on a file in the EXPLORER or OPEN EDITORS list and selecting Select for Compare and then right-click on the second file to compare with and select Compare with <file_name_you_chose>.
Alternatively from the keyboard hit Ctrl + Shift + P and select menu File → Compare Active File With... and you will be presented with a list of recent files. Example:
Vscode itself is able to show differences between any two files:
code --diff file1.txt file2.txt
i believe this is independent from git diff feature.
For a quick single file diff view in VSCode without further integrated navigation and edit experience you can configure and use the git difftool as explained by other answers - or more safe (and global) like this:
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
git config --global diff.tool vscode # optionally as default
For a fully integrated experience for such kind of custom diff in VSCode do like this:
# possibly commit or stash a dirty work tree before switching
git switch origin/master --detach # new master in worktree
git reset master # old master as detached HEAD (diff base)
Now you can see and use this "custom diff" as usual in VSCode - as a diff of worktree vs. HEAD : Use the git SCM icon, double/right-click on file changes, toggle inline diff view, etc. .
Now you can even work directly on that worktree right in the diff view. To make a commit of such changes do like:
git reset origin/master # base for added changes only
# review the bare added delta again (in VSCode)
git add/commit ...
git branch/tag my_master_fixup # name it
Then merge the new master as usual, switch back to feature branch, possibly cherry-pick the my_master_fixup, rebase or whatever ..
To make this answer work, we must follow a few steps, which, despite having been already repeated in previous answers, I'll rewrite them for sake of completeness.
Open the file ~/.gitconfig, and add the following lines:
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
In some of the answers, the next suggested step is doing git difftool <local_branch> origin/<remote_branch>.
However, there's also another possibility:
git fetch origin <remote_branch>
git difftool FETCH_HEAD
Also, to prevent those annoying prompts from showing up, we can always do:
git config --global difftool.prompt false
From v1.48 release notes:
As you navigate the Source Control view, pressing Space on a change
will now open it as a preview editor and keep the focus in the Source
Control view, for easier keyboard navigation.
So you could downarrow through your scm file changes and hit Space to open a diff view.. Focus remains in the SCM view so you could keep doing this.
Here another way to compare against the previous versions.
On the Explorer panel.
choose a file to compare, then open context menu (right click), then choose Select for Compare.
again, open context menu, then select Open Timeline. Wait for loading previous changes.
On the Timeline tab, you can select a previous version and open the context menu and click Compare with Selected.
Then you will see diff files side by side.

Using external diff tool in Gitkraken

I have installed Beyond Compare and want to use it as both merge and diff tool inside Gitkraken.
When I select any of the modified files, it still uses the default Gitkraken diff view... I know it does say merge tool in the settings, but there must be a way to specify a diff tool too, right?
This is now a working feature on GitKraken. On the commit details pane, if you right click on a file, it gives the option of opening in the external tool.
GitKraken 7.4.0:
File -> Preferences -> General -> External Diff Tool

Anyway to use an external diff editor in Eclipse with EGit?

Is there anyway to configure Eclipse/EGit to use an external diff editor and merge tool when doing differences/merges? I've been looking for a way to use something like BeyondCompare or DiffMerge or Kaleidoscope, but so far haven't found anyway to configure it.
I realize that BC has their own plugin, but it does not work within Egit context (ie: when looking at history and comparing to working tree, etc).
I'm running Eclipse 3.7SR2 (Indigo) and eGit 2.1.0. I've tried putting stuff in my .gitconfig to use external diff tools, but Eclipse still opens the files in its own compare windows.
This is currently not supported by EGit, see bug 356832 which tracks this enhancement and also includes a workaround.
As a workaround, you could try the eclipse plugin "External Compare" (see https://sourceforge.net/projects/externalcompare). This plugin opens the contents of the internal eclipse editor in an external editor.
You can use kdiff3 for GIT merging and diffing in Eclipse:
Follow these steps to set up kdiff3 to merge git conflicts within eclipse :
Let git create a config file
can be skipped if there is already a .gitconfig file in your userdir.
Windows users:
%userprofile% (copy paste in Explorer adress bar)
a file named ".gitconfig" needs to exist there
1.1 open a cmd window, execute:
git config --global --edit
The config file was created.
Open the config file ".gitconfig"
2.1 add the following lines to register kdiff3 as the diff and merge tool for git (customize the paths to you needs):
[difftool "kdiff3"]
path = "C:\Program Files\KDiff3/kdiff3.exe"
#
[mergetool "kdiff3"]
path = "C:\Program Files\KDiff3/kdiff3.exe"
#trustExitCode = true
#
Note: This would be the location to register any other supprted mergetool of your liking.
Create a new "Program" "External Tools Configuration" named "git merge" to execute merges from within eclipse!
3.1 Select the following for the parameters:
Location:
C:\Program Files\Git\bin\git.exe
Working directory:
${git_work_tree}
Arguments:
mergetool --tool=kdiff3
To execute a merge, use the standard eclipse merge and as soon as the workspace shows the conflicted state (red markers on projects visible) you mark a project you wish to merge and start the "external tools configuration" we created in the steps listed above.
The merge will start and the kdiff3 window will pop up.
from now just go along your business and only save the files when you are happy with the merge result, as kdiff will deliver a positive merge feedback if you have saved the file.

Eclipse and EGit: How to easily review changes to ALL modified files before committing to *local* repository

I'm using Eclipse Indigo SR2 with the (built-in) EGit plugin v.1.3.0.201202151440-r and haven't been able to find any way to easily review all my changes before making a commit.
I used Eclipse with SVN for years, and this was always very easy to do. I would typically right-click on my project, select Team->Synchronize, double-click on the first changed file (in the Team Sync perspective), then hit Ctrl-. repeatedly to review all changes in one file, and then proceed to the next file, as I wrote a summary of my changes for the commit message.
But of course, git is very different from Subversion, and so my workflow must change. With EGit, "Team Sync" only appears to be useful for reviewing changes between my local files and the remote repository (i.e. before a push to the remote). I need a way to review changes since my last commit to my local repository. I generally don't even care to (re)review changes before a push to remote (and if I did, I'd prefer a simple equivalent of git log to see what commits I'm about to push).
If I right-click on my project and select Team->Commit, I am presented with a window that does almost everything I need to do (select files to stage, commit, write a commit message, amend a previous commit, etc.). What it doesn't allow me to do is quickly and easily review all my changes in a compare editor. I can't believe this capability doesn't exist! It seems I am required to double-click on each individual file, review the changes, close the compare editor, and double-click on the next file. That's ridiculous!
TL/DR - I am looking for a simple GUI equivalent (in Eclipse) to do what I am easily able to do from the command line using git vimdiff (where vimdiff is a git alias that uses vimdiff as the "difftool" to cycle through all modified files) followed by git commit (with perhaps a git add or two in between).
If no one has a good solution, I am curious about how others handle their commit workflow with EGit. I've been getting along fine committing from the command line (not that Eclipse is happy about that) but I can't believe that EGit is as near-useless as it seems to me. Perhaps my google-fu is not as strong as it once was?
Says here that you can see the diffs between the working tree and any given reference. Perhaps you should try out the latest version (Juno) of Eclipse/EGit and see if it's gotten any better?
Update: I've tried this out in the latest Eclipse, and as far as I can see it works fine. Here's how:
In the moment of writing this, Eclipse Juno 4.2 is the version you should go for. On the download page, you can pick between several packages according to your needs. The 'Eclipse IDE for Java Developers' comes bundled with EGit, but you can also install EGit into any distribution using the Eclipse Marketplace (under the Help menu).
Once you've imported your project into Eclipse, make sure the project is "shared":
Right-click project -> Team -> Share Project.. -> Git
Now do the following:
Switch to the Team Synchronizing Perspective.
Click the little synchronize button in the Synchronize View.
Choose Git
Pick a suitable branch to sync against, like refs/remotes/origin/master
Make sure to check the "Include local uncommitted changes in comparison" box
Click Finish
Now, change some files and watch them appear in the Synchronize View. Double-click the changed files to see the diff (like in the screenshot below).
Are you aware of the 'Git Staging' view. It keeps track of all the files that have changed and you can review the changes any time. (This can be a bit better than using the commit dialog)
An alternative is to commit all changes without reviewing, and then use the history view to compare two commits (Simply select the last top most commits, right click and select 'Compare with each other'). This way you do not have to keep double clicking individual files. If you need to change something you can always 'Amend' the last commit. (I usually follow this approach)
I am writing this as of Eclipse Oxygen, but it should apply to other versions as well.
Option 1 with team synchronizing view: right click the project > Compare with > Commit. You can choose your latest commit here, even if you haven't pushed it to repository.
Option 2 with diff view: If you want to see the "diff" version without committing, you can achieve this by right clicking your project > team > stashes > Stash Changes > check Include untracked files. This will save all of your changes to a stash. Then you will right click project > team > stashes > select stash you saved. You click the green arrow at the top right to re-apply all of your changes you stashed back to your code. In the same stash window, you will see a "Diff" tab at the bottom right. Clicking on the diff tab will show your changes in the red/green highlighted diff style. I wish there was a way to generate a diff view without stashing, but this is the only work-around I have found.

How do I visually diff two revisions of files in TortoiseHg 2.0.3?

In TortoiseHg 1.7, I could point Hg Repository Explorer at file and see a list of versions. Selecting 2 versions and right-clicking allowed me to launch my favorite Visual Diff tool to display their differences.
I recently upgraded to TortoiseHg 2.0.3 and can't find a way to visually diff anything except the working file with the tip version. "Revision History" shows a list similar to the old Repo Explorer, but doesn't seem to have a way to lanch a visual diff. Has this featured been removed?
As noted by #dls, you can get a visual diff of any two revisions of the repo by:
Clicking on the first revision
Holding CTRL and and left-clicking on the second revision
Right-click on either revision
From the context menu, select Visual diff...
This method works with your user-defined external diff program (default is kdiff3)
TortoiseHg v2.0.x also includes a feature to diff arbitrary versions of a single file.
Open the manifest window
Right-click on the file
Select Compare file revisions
This opens the Hg file log viewer as shown below:
From this window, you can diff arbitrary versions of the file. Select the before revision in the upper-left. Select the after revision in the upper-right. The bottom half of the window shows a visual diff.
A co-worker found the answer on bitbucket. This feature was not implemented in TortoiseHg 2. It will probably be added to the next release in July. See: https://bitbucket.org/tortoisehg/thg/issue/260/visual-diff-button-in-hg-log-viewer
I'm pretty sure you can do this diff in TortoiseHg v2.0.3 - try selecting one revision by clicking and then CTRL-clicking on another revision and selecting "Visual Diff...".
I can't test this right now because I have to use v1.1.7 for unrelated reasons, but during my time working with v2.0.X I was able to do this. The bitbucket link you included looks like it's for a button to perform the visual diff, not the underlying feature.
NOTE: I was able to get a co-worker to test this, it does work (at least in some fashion) in TortoiseHg v2.0.3