Autogenerated man pages for 36de72aa9dc3b7daf8cf2770c840f39bb0d2ae70
[git.git] / man1 / git-reset.1
1 .\"Generated by db2man.xsl. Don't modify this, modify the source.
2 .de Sh \" Subsection
3 .br
4 .if t .Sp
5 .ne 5
6 .PP
7 \fB\\$1\fR
8 .PP
9 ..
10 .de Sp \" Vertical space (when we can't use .PP)
11 .if t .sp .5v
12 .if n .sp
13 ..
14 .de Ip \" List item
15 .br
16 .ie \\n(.$>=3 .ne \\$3
17 .el .ne 3
18 .IP "\\$1" \\$2
19 ..
20 .TH "GIT-RESET" 1 "" "" ""
21 .SH NAME
22 git-reset \- Reset current HEAD to the specified state.
23 .SH "SYNOPSIS"
24
25
26 git\-reset [\-\-mixed | \-\-soft | \-\-hard] [<commit\-ish>]
27
28 .SH "DESCRIPTION"
29
30
31 Sets the current head to the specified commit and optionally resets the index and working tree to match\&.
32
33
34 This command is useful if you notice some small error in a recent commit (or set of commits) and want to redo that part without showing the undo in the history\&.
35
36
37 If you want to undo a commit other than the latest on a branch, \fBgit\-revert\fR(1) is your friend\&.
38
39 .SH "OPTIONS"
40
41 .TP
42 \-\-mixed
43 Resets the index but not the working tree (ie, the changed files are preserved but not marked for commit) and reports what has not been updated\&. This is the default action\&.
44
45 .TP
46 \-\-soft
47 Does not touch the index file nor the working tree at all, but requires them to be in a good order\&. This leaves all your changed files "Updated but not checked in", as \fBgit\-status\fR(1) would put it\&.
48
49 .TP
50 \-\-hard
51 Matches the working tree and index to that of the tree being switched to\&. Any changes to tracked files in the working tree since <commit\-ish> are lost\&.
52
53 .TP
54 <commit\-ish>
55 Commit to make the current HEAD\&.
56
57 .SS "Examples"
58
59 .TP
60 Undo a commit and redo
61
62 .IP
63 $ git commit \&.\&.\&.
64 $ git reset \-\-soft HEAD^ 
65 $ edit 
66 $ git commit \-a \-c ORIG_HEAD 
67
68  This is most often done when you remembered what you
69 just committed is incomplete, or you misspelled your commit
70 message, or both\&.  Leaves working tree as it was before "reset"\&.
71  make corrections to working tree files\&.
72  "reset" copies the old head to \&.git/ORIG_HEAD; redo the
73 commit by starting with its log message\&.  If you do not need to
74 edit the message further, you can give \-C option instead\&.
75 .TP
76 Undo commits permanently
77
78 .IP
79 $ git commit \&.\&.\&.
80 $ git reset \-\-hard HEAD~3 
81
82  The last three commits (HEAD, HEAD^, and HEAD~2) were bad
83 and you do not want to ever see them again\&.  Do *not* do this if
84 you have already given these commits to somebody else\&.
85 .TP
86 Undo a commit, making it a topic branch
87
88 .IP
89 $ git branch topic/wip 
90 $ git reset \-\-hard HEAD~3 
91 $ git checkout topic/wip 
92
93  You have made some commits, but realize they were premature
94 to be in the "master" branch\&.  You want to continue polishing
95 them in a topic branch, so create "topic/wip" branch off of the
96 current HEAD\&.
97  Rewind the master branch to get rid of those three commits\&.
98  Switch to "topic/wip" branch and keep working\&.
99 .TP
100 Undo update\-index
101
102 .IP
103 $ edit 
104 $ git\-update\-index frotz\&.c filfre\&.c
105 $ mailx 
106 $ git reset 
107 $ git pull git://info\&.example\&.com/ nitfol 
108
109  you are happily working on something, and find the changes
110 in these files are in good order\&.  You do not want to see them
111 when you run "git diff", because you plan to work on other files
112 and changes with these files are distracting\&.
113  somebody asks you to pull, and the changes sounds worthy of merging\&.
114  however, you already dirtied the index (i\&.e\&. your index does
115 not match the HEAD commit)\&.  But you know the pull you are going
116 to make does not affect frotz\&.c nor filfre\&.c, so you revert the
117 index changes for these two files\&.  Your changes in working tree
118 remain there\&.
119  then you can pull and merge, leaving frotz\&.c and filfre\&.c
120 changes still in the working tree\&.
121 .TP
122 Undo a merge or pull
123
124 .IP
125 $ git pull 
126 Trying really trivial in\-index merge\&.\&.\&.
127 fatal: Merge requires file\-level merging
128 Nope\&.
129 \&.\&.\&.
130 Auto\-merging nitfol
131 CONFLICT (content): Merge conflict in nitfol
132 Automatic merge failed/prevented; fix up by hand
133 $ git reset \-\-hard 
134
135  try to update from the upstream resulted in a lot of
136 conflicts; you were not ready to spend a lot of time merging
137 right now, so you decide to do that later\&.
138  "pull" has not made merge commit, so "git reset \-\-hard"
139 which is a synonym for "git reset \-\-hard HEAD" clears the mess
140 from the index file and the working tree\&.
141
142 $ git pull \&. topic/branch 
143 Updating from 41223\&.\&.\&. to 13134\&.\&.\&.
144 Fast forward
145 $ git reset \-\-hard ORIG_HEAD 
146
147  merge a topic branch into the current branch, which resulted
148 in a fast forward\&.
149  but you decided that the topic branch is not ready for public
150 consumption yet\&.  "pull" or "merge" always leaves the original
151 tip of the current branch in ORIG_HEAD, so resetting hard to it
152 brings your index file and the working tree back to that state,
153 and resets the tip of the branch to that commit\&.
154 .SH "AUTHOR"
155
156
157 Written by Junio C Hamano <junkio@cox\&.net> and Linus Torvalds <torvalds@osdl\&.org>
158
159 .SH "DOCUMENTATION"
160
161
162 Documentation by Junio C Hamano and the git\-list <git@vger\&.kernel\&.org>\&.
163
164 .SH "GIT"
165
166
167 Part of the \fBgit\fR(7) suite
168