【发布时间】:2014-10-22 13:46:40
【问题描述】:
在recent answer 中,他详细介绍了git-reset 三个最常用选项(--hard、--mixed 和--soft)的典型用例,torek 顺便提到了@ 987654330@ 还提供了两个相对深奥的标志,称为--merge 和--keep。 git-reset man page 描述这两个标志如下:
--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.
我完全理解何时使用--hard、--mixed或--soft,但我在阅读torek的答案时才知道--merge和--keep存在,我想不出实际用例这两个标志中的......您通常在什么情况下使用这两个标志?
我主要是在寻找一个简单的英语解释。以this answer by VonC 的以下段落为例,该段落阐述了git reset --soft 的典型用例:
[...] 每次:
- 您对最终得到的结果感到满意(就工作树和索引而言)
- 您对所有带您到达那里的提交都不满意:
git reset --soft就是答案。
但是,我并不反对对这些标志进行一些小实验,在精神上类似于我在 this answer of mine 中发布的愚蠢购物清单示例。
【问题讨论】: