Skip to main content

6.4 Applying

Magit provides several "apply variants": stage, unstage, discard, reverse, and "regular apply". At least when operating on a hunk they are all implemented using git apply, which is why they are called "apply variants".

  • Stage. Apply a change from the working tree to the index. The change also remains in the working tree.
  • Unstage. Remove a change from the index. The change remains in the working tree.
  • Discard. On a staged change, remove it from the working tree and the index. On an unstaged change, remove it from the working tree only.
  • Reverse. Reverse a change in the working tree. Both committed and staged changes can be reversed. Unstaged changes cannot be reversed. Discard them instead.
  • Apply. Apply a change to the working tree. Both committed and staged changes can be applied. Unstaged changes cannot be applied - as they already have been applied.

The previous section described the staging and unstaging commands. What follows are the commands which implement the remaining apply variants.

a     (magit-apply)​

Apply the change at point to the working tree.

With a prefix argument fallback to a 3-way merge. Doing so causes the change to be applied to the index as well.

k     (magit-discard)​

Remove the change at point from the working tree.

On a hunk or file with unresolved conflicts prompt which side to keep (while discarding the other). If point is within the text of a side, then keep that side without prompting.

v     (magit-reverse)​

Reverse the change at point in the working tree.

With a prefix argument fallback to a 3-way merge. Doing so causes the change to be applied to the index as well.

With a prefix argument all apply variants attempt a 3-way merge when appropriate (i.e. when git apply is used internally).