@matheusbsbs / matheus-bagliano / commits / 3ae854c356
Fork 0

Examples of resetting.

Morten Welinder says examples of resetting is really about recovering from botched commit/pulls. I agree that pointers from commands that cause a reset to be needed in the first place would be very helpful. Also reset examples did not mention "pull/merge" cases. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 16, 2005 at 18:23 UTC 3ae854c3567dd10055fbe12b8bd91bd2d447f55f
4 files changed +47
Documentation/git-commit.txt
+4
@@ -66,6 +66,10 @@ OPTIONS
66 Update specified paths in the index file before committing.
67
68
69 +If you make a commit and then found a mistake immediately after
70 +that, you can recover from it with gitlink:git-reset[1].
71 +
72 +
73 Author
74 ------
75 Written by Linus Torvalds <torvalds@osdl.org> and
Documentation/git-merge.txt
+5
@@ -37,6 +37,11 @@ include::merge-options.txt[]
37 include::merge-strategies.txt[]
38
39
40 +If you tried a merge which resulted in a complex conflicts and
41 +would want to start over, you can recover with
42 +gitlink:git-reset[1].
43 +
44 +
45 HOW MERGE WORKS
46 ---------------
47
Documentation/git-pull.txt
+5
@@ -104,6 +104,11 @@ merge the remote `origin` head into the current,
104 local `master` branch.
105
106
107 +If you tried a pull which resulted in a complex conflicts and
108 +would want to start over, you can recover with
109 +gitlink:git-reset[1].
110 +
111 +
112 SEE ALSO
113 --------
114 gitlink:git-fetch[1], gitlink:git-merge[1]
Documentation/git-reset.txt
+33
@@ -111,6 +111,39 @@ remain there.
111 changes still in the working tree.
112 ------------
113
114 +Undo a merge or pull::
115 ++
116 +------------
117 +$ git pull <1>
118 +Trying really trivial in-index merge...
119 +fatal: Merge requires file-level merging
120 +Nope.
121 +...
122 +Auto-merging nitfol
123 +CONFLICT (content): Merge conflict in nitfol
124 +Automatic merge failed/prevented; fix up by hand
125 +$ git reset --hard <2>
126 +
127 +<1> try to update from the upstream resulted in a lot of
128 +conflicts; you were not ready to spend a lot of time merging
129 +right now, so you decide to do that later.
130 +<2> "pull" has not made merge commit, so "git reset --hard"
131 +which is a synonym for "git reset --hard HEAD" clears the mess
132 +from the index file and the working tree.
133 +
134 +$ git pull . topic/branch <3>
135 +Updating from 41223... to 13134...
136 +Fast forward
137 +$ git reset --hard ORIG_HEAD <4>
138 +
139 +<3> merge a topic branch into the current branch, which resulted
140 +in a fast forward.
141 +<4> but you decided that the topic branch is not ready for public
142 +consumption yet. "pull" or "merge" always leaves the original
143 +tip of the current branch in ORIG_HEAD, so resetting hard to it
144 +brings your index file and the working tree back to that state,
145 +and resets the tip of the branch to that commit.
146 +------------
147
148 Author
149 ------