git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rebase: introduce --update-branches option

From
WHWarren He <pickydaemon@gmail.com>
Date
Sep 2, 2019, 23:41 UTC
Message-ID
<20190902234109.2922-1-wh109@yahoo.com>

Sometimes people have to rebase multiple related branches. One way to do that quickly, when there are branches pointing to ancestors of a later branch (which happens a lot if you try hard to pad your PR count on GitHub--I mean if you try to make small, logically separate changes), is to rebase that later branch and then reset ancestor branches to the rewritten commits. You just have to work out which branches correspond to which of the new commits.

Here's an automated way to update those ancestor branches.

It's implemented as a function that processes a todo list, modeled after `todo_list_add_exec_commands`. Currently steps are added as `exec git branch -f <branchname>`, which comes with the caveat that they're not applied atomically when it finishes rebasing.

If you were to use this feature to rebase `my-dev` onto `master` in this situation:

```
 A - B          (master)
  |\
  |  E          (feat-e)
   \   \
     F  |       (feat-f)
       \|
         G      (interim)
           \
             H  (my-dev)
```
you'd get a todo list like this:

``` label onto

# Branch G reset onto pick 65945ab E exec git branch -f feat-e label G

reset onto pick 4f0b0ad F exec git branch -f feat-f merge -C e50066c G # G exec git branch -f interim pick 539e556 H ```

Warren He (1):
  rebase: introduce --update-branches option
 Documentation/git-rebase.txt      |  8 +++++
 builtin/rebase.c                  | 13 ++++++--
 sequencer.c                       | 68 ++++++++++++++++++++++++++++++++++++++-
 sequencer.h                       |  6 ++--
 t/t3431-rebase-update-branches.sh | 64 ++++++++++++++++++++++++++++++++++++
 5 files changed, 154 insertions(+), 5 deletions(-)
 create mode 100755 t/t3431-rebase-update-branches.sh
-- 
2.7.4
Next: Warren He
Message 1 of 16 in “rebase: introduce --update-branches option”
  1. rebase: introduce --update-branches optionWarren He, Sep 2, 2019
  2. rebase: introduce --update-branches optionWarren He, Sep 2, 2019
  3. Johannes SchindelinSep 3, 2019
  4. rebase: introduce --update-branches optionWarren He, Sep 7, 2019
  5. rebase: introduce --update-branches optionWarren He, Sep 7, 2019
  6. Phillip WoodSep 9, 2019
  7. Johannes SchindelinSep 9, 2019
  8. Junio C HamanoSep 9, 2019
  9. Phillip WoodSep 23, 2019
  10. brian m. carlsonSep 3, 2019
  11. Junio C HamanoSep 3, 2019
  12. Taylor BlauSep 3, 2019
  13. Warren HeSep 7, 2019
  14. brian m. carlsonSep 8, 2019
  15. Phillip WoodSep 3, 2019
  16. Warren HeSep 7, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.