In a recent answer in which he details the typical use cases of git-reset
's three most commonly used options (--hard
, --mixed
, and --soft
), torek mentions in passing that git-reset
also offers two relatively esoteric flags, called --merge
and --keep
. The git-reset
man page describes those two flags as follows:
--merge Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted. In other words, --merge does something like a git read-tree -u -m <commit>, but carries forward unmerged index entries. --keep Resets index entries and updates files in the working tree that are different between <commit> and HEAD. If a file that is different between <commit> and HEAD has local changes, reset is aborted.
I perfectly understand when to use --hard
, --mixed
, or --soft
, but I only learned that --merge
and --keep
existed while reading torek's answer, and I can't think of practical use cases of those two flags... In what situations do you typically use those two flags?
I'm mainly looking for a plain-English explanation. Take the following passage of this answer by VonC, which spells out a typical use case for git reset --soft
, as a model:
[...] each time:
- you are satisfied with what you end up with (in term of working tree and index)
- you are not satisfied with all the commits that took you to get there:
git reset --soft
is the answer.
However, I'm not averse to a little experiment with those flags, similar in spirit to the silly shopping-list example I posted in this answer of mine.