@@ -170,6 +170,38 @@ To see a linear list of commits for this branch::
170
170
171
171
git log
172
172
173
+
174
+ .. _recovering-from-mess-up :
175
+
176
+ Recovering from mess-ups
177
+ ------------------------
178
+
179
+ Sometimes, you mess up merges or rebases. Luckily, in git it is
180
+ relatively straightforward to recover from such mistakes.
181
+
182
+ If you mess up during a rebase::
183
+
184
+ git rebase --abort
185
+
186
+ If you notice you messed up after the rebase::
187
+
188
+ # reset branch back to the saved point
189
+ git reset --hard tmp
190
+
191
+ If you forgot to make a backup branch::
192
+
193
+ # look at the reflog of the branch
194
+ git reflog show cool-feature
195
+
196
+ 8630830 cool-feature@{0}: commit: BUG: io: close file handles immediately
197
+ 278dd2a cool-feature@{1}: rebase finished: refs/heads/my-feature-branch onto 11ee694744f2552d
198
+ 26aa21a cool-feature@{2}: commit: BUG: lib: make seek_gzip_factory not leak gzip obj
199
+ ...
200
+
201
+ # reset the branch to where it was before the botched rebase
202
+ git reset --hard cool-feature@{2}
203
+
204
+
173
205
.. _rebase-on-main :
174
206
175
207
Rebasing on ``upstream/main ``
@@ -242,36 +274,6 @@ some related help on merging in the git user manual - see `resolving a merge`_.
242
274
.. _resolving a merge : https://schacon.github.io/git/user-manual.html#resolving-a-merge
243
275
244
276
245
- .. _recovering-from-mess-up :
246
-
247
- Recovering from mess-ups
248
- ------------------------
249
-
250
- Sometimes, you mess up merges or rebases. Luckily, in git it is
251
- relatively straightforward to recover from such mistakes.
252
-
253
- If you mess up during a rebase::
254
-
255
- git rebase --abort
256
-
257
- If you notice you messed up after the rebase::
258
-
259
- # reset branch back to the saved point
260
- git reset --hard tmp
261
-
262
- If you forgot to make a backup branch::
263
-
264
- # look at the reflog of the branch
265
- git reflog show cool-feature
266
-
267
- 8630830 cool-feature@{0}: commit: BUG: io: close file handles immediately
268
- 278dd2a cool-feature@{1}: rebase finished: refs/heads/my-feature-branch onto 11ee694744f2552d
269
- 26aa21a cool-feature@{2}: commit: BUG: lib: make seek_gzip_factory not leak gzip obj
270
- ...
271
-
272
- # reset the branch to where it was before the botched rebase
273
- git reset --hard cool-feature@{2}
274
-
275
277
.. _rewriting-commit-history :
276
278
277
279
Rewriting commit history
0 commit comments