1 .\"Generated by db2man.xsl. Don't modify this, modify the source.
10 .de Sp \" Vertical space (when we can't use .PP)
16 .ie \\n(.$>=3 .ne \\$3
20 .TH "GIT-RESET" 1 "" "" ""
22 git-reset \- Reset current HEAD to the specified state.
26 git\-reset [\-\-mixed | \-\-soft | \-\-hard] [<commit\-ish>]
31 Sets the current head to the specified commit and optionally resets the index and working tree to match\&.
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\&.
37 If you want to undo a commit other than the latest on a branch, \fBgit\-revert\fR(1) is your friend\&.
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\&.
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\&.
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\&.
55 Commit to make the current HEAD\&.
60 Undo a commit and redo
63 $ git commit \&.\&.\&.
64 $ git reset \-\-soft HEAD^
66 $ git commit \-a \-c ORIG_HEAD
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\&.
76 Undo commits permanently
79 $ git commit \&.\&.\&.
80 $ git reset \-\-hard HEAD~3
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\&.
86 Undo a commit, making it a topic branch
89 $ git branch topic/wip
90 $ git reset \-\-hard HEAD~3
91 $ git checkout topic/wip
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
97 Rewind the master branch to get rid of those three commits\&.
98 Switch to "topic/wip" branch and keep working\&.
104 $ git\-update\-index frotz\&.c filfre\&.c
107 $ git pull git://info\&.example\&.com/ nitfol
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
119 then you can pull and merge, leaving frotz\&.c and filfre\&.c
120 changes still in the working tree\&.
126 Trying really trivial in\-index merge\&.\&.\&.
127 fatal: Merge requires file\-level merging
131 CONFLICT (content): Merge conflict in nitfol
132 Automatic merge failed/prevented; fix up by hand
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\&.
142 $ git pull \&. topic/branch
143 Updating from 41223\&.\&.\&. to 13134\&.\&.\&.
145 $ git reset \-\-hard ORIG_HEAD
147 merge a topic branch into the current branch, which resulted
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\&.
157 Written by Junio C Hamano <junkio@cox\&.net> and Linus Torvalds <torvalds@osdl\&.org>
162 Documentation by Junio C Hamano and the git\-list <git@vger\&.kernel\&.org>\&.
167 Part of the \fBgit\fR(7) suite