This section describes how to enter Ediff from Magit buffers. For information on how to use Ediff itself, see (ediff)Top.
magit-ediff-dwim
) ¶Compare, stage, or resolve using Ediff.
This command tries to guess what file, and what commit or range the
user wants to compare, stage, or resolve using Ediff. It might only
be able to guess either the file, or range/commit, in which case
the user is asked about the other. It might not always guess right,
in which case the appropriate magit-ediff-*
command has to be used
explicitly. If it cannot read the user’s mind at all, then it asks
the user for a command to run.
magit-ediff
) ¶This transient prefix command binds the following suffix commands and displays them in a temporary buffer until a suffix is invoked.
magit-ediff-compare
) ¶Compare two revisions of a file using Ediff.
If the region is active, use the revisions on the first and last line of the region. With a prefix argument, instead of diffing the revisions, choose a revision to view changes along, starting at the common ancestor of both revisions (i.e., use a "…" range).
magit-ediff-resolve-rest
) ¶This command allows you to resolve outstanding conflicts in the file at point using Ediff. If there is no file at point or if it doesn’t have any unmerged changes, then this command prompts for a file.
Provided that the value of merge.conflictstyle
is diff3
, you can
view the file’s merge-base revision using /
in the Ediff control
buffer.
The A, B and Ancestor buffers are constructed from the conflict markers in the worktree file. Because you and/or Git may have already resolved some conflicts, that means that these buffers may not contain the actual versions from the respective blobs.
magit-ediff-resolve-all
) ¶This command allows you to resolve all conflicts in the file at point using Ediff. If there is no file at point or if it doesn’t have any unmerged changes, then this command prompts for a file.
Provided that the value of merge.conflictstyle
is diff3
, you can
view the file’s merge-base revision using /
in the Ediff control
buffer.
First the file in the worktree is moved aside, appending the suffix ‘.ORIG’, so that you could later go back to that version. Then it is reconstructed from the two sides of the conflict and the merge-base, if available.
It would be nice if the worktree file were just used as-is, but Ediff does not support that. This means that all conflicts, that Git has already resolved, are restored. On the other hand Ediff also tries to resolve conflicts, and in many cases Ediff and Git should produce similar results.
However if you have already resolved some conflicts manually, then
those changes are discarded (though you can recover them from the
backup file). In such cases magit-ediff-resolve-rest
might be more
suitable.
The advantage that this command has over magit-ediff-resolve-rest
is that the A, B and Ancestor buffers correspond to blobs from the
respective commits, allowing you to inspect a side in context and
to use Magit commands in these buffers to do so. Blame and log
commands are particularly useful here.
magit-git-mergetool
) ¶This command does not actually use Ediff. While it serves the same purpose as ‘magit-ediff-resolve-rest’, it uses ‘git mergetool --gui’ to resolve conflicts.
With a prefix argument this acts as a transient prefix command, allowing the user to select the mergetool and change some settings.
magit-ediff-stage
) ¶Stage and unstage changes to a file using Ediff, defaulting to the file at point.
magit-ediff-show-unstaged
) ¶Show unstaged changes to a file using Ediff.
magit-ediff-show-staged
) ¶Show staged changes to a file using Ediff.
magit-ediff-show-working-tree
) ¶Show changes in a file between HEAD
and working tree using Ediff.
magit-ediff-show-commit
) ¶Show changes to a file introduced by a commit using Ediff.
magit-ediff-show-stash
) ¶Show changes to a file introduced by a stash using Ediff.
This option controls which function magit-ediff-dwim
uses to resolve
conflicts. One of magit-ediff-resolve-rest
, magit-ediff-resolve-all
or magit-git-mergetool
; which are all discussed above.
This option controls what command magit-ediff-dwim
calls when
point is on uncommitted hunks. When nil, always run
magit-ediff-stage
. Otherwise, use magit-ediff-show-staged
and
magit-ediff-show-unstaged
to show staged and unstaged changes,
respectively.
This option controls whether magit-ediff-show-stash
includes a
buffer containing the file’s state in the index at the time the
stash was created. This makes it possible to tell which changes in
the stash were staged.
This hook is run after quitting an Ediff session that was created using a Magit command. The hook functions are run inside the Ediff control buffer, and should not change the current buffer.
This is similar to ediff-quit-hook
but takes the needs of Magit into
account. The regular ediff-quit-hook
is ignored by Ediff sessions
that were created using a Magit command.