@@ -40,7 +40,7 @@ workflow is:
4040
4141#. Start a new *feature branch * from ``upstream/main ``::
4242
43- git checkout -b my-feature upstream/main
43+ git checkout -b my-new- feature upstream/main
4444
4545#. When you're done editing, e.g., ``lib/matplotlib/collections.py ``, record your changes in Git::
4646
@@ -49,7 +49,7 @@ workflow is:
4949
5050#. Push the changes to your GitHub fork::
5151
52- git push -u origin my-feature
52+ git push -u origin my-new- feature
5353
5454
5555.. _update-mirror-main :
@@ -232,15 +232,15 @@ If you notice you messed up after the rebase::
232232If you forgot to make a backup branch::
233233
234234 # look at the reflog of the branch
235- git reflog show cool -feature
235+ git reflog show my-new -feature
236236
237- 8630830 cool -feature@{0}: commit: BUG: io: close file handles immediately
238- 278dd2a cool- feature@{1}: rebase finished: refs/heads/my-feature-branch onto 11ee694744f2552d
239- 26aa21a cool -feature@{2}: commit: BUG: lib: make seek_gzip_factory not leak gzip obj
237+ 8630830 my-new -feature@{0}: commit: BUG: io: close file handles immediately
238+ 278dd2a my-new- feature@{1}: rebase finished: refs/heads/my-new-feature onto 11ee694744f2552d
239+ 26aa21a my-new -feature@{2}: commit: BUG: lib: make seek_gzip_factory not leak gzip obj
240240 ...
241241
242242 # reset the branch to where it was before the botched rebase
243- git reset --hard cool -feature@{2}
243+ git reset --hard my-new -feature@{2}
244244
245245.. _rewriting-commit-history :
246246
@@ -258,73 +258,85 @@ This can be done via *interactive rebasing*.
258258
259259Suppose that the commit history looks like this::
260260
261- git log --oneline
262- eadc391 Fix some remaining bugs
263- a815645 Modify it so that it works
264- 2dec1ac Fix a few bugs + disable
265- 13d7934 First implementation
266- 6ad92e5 * masked is now an instance of a new object, MaskedConstant
267- 29001ed Add pre-nep for a copule of structured_array_extensions.
261+ $ git log --oneline
262+ b7e99a8659 (HEAD -> my-new-feature) Fix some remaining bugs
263+ 8a5de78b17 Modify it so that it works
264+ 34448c69eb Fix a few bugs + disable
265+ 9a5d1ca186 First implementation
266+ d1da6fbf0b (upstream/main) Merge pull request #30778 from timhoffm/decorator-tracebackhide
267+ 6ad937ad83 Merge pull request #30838 from has2k1/fix-numpy-integer-markers
268268 ...
269269
270- and ``6ad92e5 `` is the last commit in the ``cool -feature `` branch. Suppose we
270+ and ``b7e99a8659 `` is the most recent commit in the ``my-new -feature `` branch. Suppose we
271271want to make the following changes:
272272
273- * Rewrite the commit message for ``13d7934 `` to something more sensible .
274- * Combine the commits ``2dec1ac ``, ``a815645 ``, ``eadc391 `` into a single one.
273+ * Rewrite the commit message for ``9a5d1ca186 `` to something more specific .
274+ * Combine the commits ``34448c69eb ``, ``8a5de78b17 ``, ``b7e99a8659 `` into a single one.
275275
276276We do as follows::
277277
278278 # make a backup of the current state
279279 git branch tmp HEAD
280280 # interactive rebase
281- git rebase -i 6ad92e5
281+ git rebase -i d1da6fbf0b
282282
283283This will open an editor with the following text in it::
284284
285- pick 13d7934 First implementation
286- pick 2dec1ac Fix a few bugs + disable
287- pick a815645 Modify it so that it works
288- pick eadc391 Fix some remaining bugs
285+ pick 9a5d1ca186 First implementation
286+ pick 34448c69eb Fix a few bugs + disable
287+ pick 8a5de78b17 Modify it so that it works
288+ pick b7e99a8659 Fix some remaining bugs
289289
290- # Rebase 6ad92e5..eadc391 onto 6ad92e5
290+ # Rebase d1da6fbf0b..b7e99a8659 onto d1da6fbf0b (4 commands)
291291 #
292292 # Commands:
293- # p, pick = use commit
294- # r, reword = use commit, but edit the commit message
295- # e, edit = use commit, but stop for amending
296- # s, squash = use commit, but meld into previous commit
297- # f, fixup = like "squash", but discard this commit's log message
293+ # p, pick <commit> = use commit
294+ # r, reword <commit> = use commit, but edit the commit message
295+ # e, edit <commit> = use commit, but stop for amending
296+ # s, squash <commit> = use commit, but meld into previous commit
297+ # f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
298+ # commit's log message, unless -C is used, in which case
299+ # keep only this commit's message; -c is same as -C but
300+ # opens the editor
301+ # x, exec <command> = run command (the rest of the line) using shell
302+ # b, break = stop here (continue rebase later with 'git rebase --continue')
303+ # d, drop <commit> = remove commit
304+ # l, label <label> = label current HEAD with a name
305+ # t, reset <label> = reset HEAD to a label
306+ # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
307+ # create a merge commit using the original merge commit's
308+ # message (or the oneline, if no original merge commit was
309+ # specified); use -c <commit> to reword the commit message
310+ # u, update-ref <ref> = track a placeholder for the <ref> to be updated
311+ # to this position in the new commits. The <ref> is
312+ # updated at the end of the rebase
313+ #
314+ # These lines can be re-ordered; they are executed from top to bottom.
298315 #
299316 # If you remove a line here THAT COMMIT WILL BE LOST.
317+ #
300318 # However, if you remove everything, the rebase will be aborted.
301319 #
302320
303321To achieve what we want, we will make the following changes to it::
304322
305- r 13d7934 First implementation
306- pick 2dec1ac Fix a few bugs + disable
307- f a815645 Modify it so that it works
308- f eadc391 Fix some remaining bugs
323+ r 9a5d1ca186 First implementation
324+ pick 34448c69eb Fix a few bugs + disable
325+ f 8a5de78b17 Modify it so that it works
326+ f b7e99a8659 Fix some remaining bugs
309327
310328This means that (i) we want to edit the commit message for
311- ``13d7934 ``, and (ii) collapse the last three commits into one. Now we
329+ ``9a5d1ca186 ``, and (ii) collapse the last three commits into one. Now we
312330save and quit the editor.
313331
314332Git will then immediately bring up an editor for editing the commit
315- message. After revising it, we get the output::
316-
317- [detached HEAD 721fc64] FOO: First implementation
318- 2 files changed, 199 insertions(+), 66 deletions(-)
319- [detached HEAD 0f22701] Fix a few bugs + disable
320- 1 files changed, 79 insertions(+), 61 deletions(-)
321- Successfully rebased and updated refs/heads/my-feature-branch.
333+ message. After revising it, the history looks like this::
322334
323- and now, the history looks like this::
324-
325- 0f22701 Fix a few bugs + disable
326- 721fc64 ENH: Sophisticated feature
327- 6ad92e5 * masked is now an instance of a new object, MaskedConstant
335+ 955f532b04 (HEAD -> my-new-feature) Fix a few bugs + disable
336+ 5a2046b5a7 Add my coolest of features
337+ d1da6fbf0b (upstream/main) Merge pull request #30778 from timhoffm/decorator-tracebackhide
338+ 6ad937ad83 Merge pull request #30838 from has2k1/fix-numpy-integer-markers
339+ ...
328340
329341If it went wrong, recovery is again possible as explained :ref: `above
330342<recovering-from-mess-up>`.
@@ -341,14 +353,14 @@ Rebase onto ``upstream/main``
341353
342354Let's say you thought of some work you'd like to do. You
343355:ref: `update-mirror-main ` and :ref: `make-feature-branch ` called
344- ``cool -feature ``. At this stage, ``main `` is at some commit, let's call it E.
345- Now you make some new commits on your ``cool -feature `` branch, let's call them
356+ ``my-new -feature ``. At this stage, ``main `` is at some commit, let's call it E.
357+ Now you make some new commits on your ``my-new -feature `` branch, let's call them
346358A, B, C. Maybe your changes take a while, or you come back to them after a
347359while. In the meantime, ``main `` has progressed from commit E to commit (say) G:
348360
349361.. code-block :: none
350362
351- A---B---C cool -feature
363+ A---B---C my-new -feature
352364 /
353365 D---E---F---G main
354366
@@ -366,7 +378,7 @@ rebase, your history will look like this:
366378
367379.. code-block :: none
368380
369- A'--B'--C' cool -feature
381+ A'--B'--C' my-new -feature
370382 /
371383 D---E---F---G main
372384
@@ -379,13 +391,13 @@ To do a rebase on ``upstream/main``::
379391 # Fetch changes from upstream/main
380392 git fetch upstream
381393 # go to the feature branch
382- git checkout cool -feature
394+ git checkout my-new -feature
383395 # make a backup in case you mess up
384- git branch tmp cool -feature
385- # rebase cool -feature onto main
386- git rebase --onto upstream/main upstream/main cool -feature
396+ git branch tmp my-new -feature
397+ # rebase my-new -feature onto main
398+ git rebase --onto upstream/main upstream/main my-new -feature
387399
388- In this situation, where you are already on branch ``cool -feature ``, the last
400+ In this situation, where you are already on branch ``my-new -feature ``, the last
389401command can be written more succinctly as::
390402
391403 git rebase upstream/main
@@ -424,13 +436,13 @@ a git history that looks something like
424436
425437.. code-block :: none
426438
427- A'--E cool -feature
439+ A'--E my-new -feature
428440 /
429- D---A---B---C origin/cool -feature
441+ D---A---B---C origin/my-new -feature
430442
431443 where you have pushed the commits ``A,B,C `` to your fork on GitHub (under the
432444remote name *origin *) but now have the commits ``A' `` and ``E `` on your local
433- branch *cool -feature *. If you try to push the new commits to GitHub, it will
445+ branch *my-new -feature *. If you try to push the new commits to GitHub, it will
434446fail and show an error that looks like ::
435447
436448 $ git push
@@ -448,7 +460,7 @@ longer be referenced by any branch and they would be discarded:
448460
449461.. code-block :: none
450462
451- D---A'---E cool- feature, origin/cool -feature
463+ D---A'---E my-new- feature, origin/my-new -feature
452464
453465 By default ``git push `` helpfully tries to protect you from accidentally
454466discarding commits by rejecting the push to the remote. When this happens,
0 commit comments