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

Inconsistancy with `git rebase --preserve-merges`

From
Robin Moussu <moussu.robin@pm.me>
Date
Feb 24, 2020, 14:10 UTC
Message-ID
<tmm3ViXf1QO5dCCNgDCHCHSZeUKUfiYvNoI9RMvdLlnOLk0oUt_w2SKgYu3LPh6no-wHhq1gXbVlBKgLcnGCR5HaTgWMx5se9KmJOKITUHk=@pm.me>
In-Reply-To
<v9k9hyJjfgQYYIczd9NqrjSdyOyxwqEB0iWyQ_TZCnobCZZoZ8_v6WB4KcWyW5xxRPdDUyEqEYfXylOnGI57CtK9KegMgp_0bz_5RrIIhHY=@pm.me>

Hi. I noticed that the position of the `--preserve-merges` option of `git rebase` is significant (I think it shouldn't).

The following snippet doesn't preserve the merges: ``` $ git rebase --preserve-merges -i 412f07a~ pick 412f07a Work on dev branch pick c6efccd Work on master branch pick 71c8c37 Some work after the merge ```

Whereas this one does what I expect: ``` $ git rebase -i 412f07a~ --preserve-merges pick 412f07a Work on dev branch pick 616064c Merge branch 'master' into dev pick 71c8c37 Some work after the merge ```

For reference:
```
$ git log --graph --oneline
* 71c8c37      (HEAD -> dev) Some work after the merge
*   616064c    Merge branch 'master' into dev
|\
| *   c6efccd  Work on master branch
| *   ... (more work on master)
* |   412f07a  Work on dev branch
* |   ... (more work on dev)
|/
* 4ee50cb Common ancestor
```
Step to reproduce:
```
mkdir temp
cd temp
git init
git commit --allow-empty -m 'Common ancestor'
git checkout -b dev
git commit --allow-empty -m 'Work on dev branch'
git tag some_commit
git checkout master
git commit --allow-empty -m 'Work on master branch'
git checkout dev
git merge master -m 'Merge branch 'master' into dev'
git commit --allow-empty -m 'Some work after the merge'
```
Then you will see that
    git rebase -i some_commit --preserve-merges
and
    git rebase --preserve-merges  -i some_commit
don't have the same output.
I am using git version 2.21.1 on Fedora 30.
Robin.
Next: Kevin Daudt
Message 1 of 3 in “Inconsistancy with `git rebase --preserve-merges`”
  1. Robin MoussuFeb 24, 2020
  2. Kevin DaudtFeb 24, 2020
  3. Junio C HamanoFeb 24, 2020

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.