Skip to content

Commit 4086010

Browse files
chriscoolgitster
authored andcommitted
Documentation: reset: add some tables to describe the different options
This patch adds a DISCUSSION section that contains some tables to show how the different "git reset" options work depending on the states of the files in the working tree, the index, HEAD and the target commit. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2b06b0a commit 4086010

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

Documentation/git-reset.txt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,72 @@ linkgit:git-add[1]).
6767
<commit>::
6868
Commit to make the current HEAD. If not given defaults to HEAD.
6969

70+
DISCUSSION
71+
----------
72+
73+
The tables below show what happens when running:
74+
75+
----------
76+
git reset --option target
77+
----------
78+
79+
to reset the HEAD to another commit (`target`) with the different
80+
reset options depending on the state of the files.
81+
82+
working index HEAD target working index HEAD
83+
----------------------------------------------------
84+
A B C D --soft A B D
85+
--mixed A D D
86+
--hard D D D
87+
--merge (disallowed)
88+
89+
working index HEAD target working index HEAD
90+
----------------------------------------------------
91+
A B C C --soft A B C
92+
--mixed A C C
93+
--hard C C C
94+
--merge (disallowed)
95+
96+
working index HEAD target working index HEAD
97+
----------------------------------------------------
98+
B B C D --soft B B D
99+
--mixed B D D
100+
--hard D D D
101+
--merge D D D
102+
103+
working index HEAD target working index HEAD
104+
----------------------------------------------------
105+
B B C C --soft B B C
106+
--mixed B C C
107+
--hard C C C
108+
--merge C C C
109+
110+
In these tables, A, B, C and D are some different states of a
111+
file. For example, the last line of the last table means that if a
112+
file is in state B in the working tree and the index, and in a
113+
different state C in HEAD and in the target, then "git reset
114+
--merge target" will put the file in state C in the working tree,
115+
in the index and in HEAD.
116+
117+
The following tables show what happens when there are unmerged
118+
entries:
119+
120+
working index HEAD target working index HEAD
121+
----------------------------------------------------
122+
X U A B --soft (disallowed)
123+
--mixed X B B
124+
--hard B B B
125+
--merge (disallowed)
126+
127+
working index HEAD target working index HEAD
128+
----------------------------------------------------
129+
X U A A --soft (disallowed)
130+
--mixed X A A
131+
--hard A A A
132+
--merge (disallowed)
133+
134+
X means any state and U means an unmerged index.
135+
70136
Examples
71137
--------
72138

0 commit comments

Comments
 (0)