rebase -p loses amended changes
- From
- J Robert Ray <jrobertray@gmail.com>
- Date
- Mar 30, 2012, 21:31 UTC
- Message-ID
- <CADb3U=4DNt7Jnzq4eW-K+W1_sEfMgL6MxqY6qmPaJZagiFdmmg@mail.gmail.com>
I've found that 'rebase -p' can discard changes from a merge commit when it recreates the merge.
If a merge is amended to add changes to a file unaffected by the merge, these changes are lost after a rebase. Attached is a script to demonstrate the problem.
I've tested the script against git 1.7.9.5.
I'll outline the steps starting from an empty repo.
1. Create a file (a) with some contents, then create three branches from this point, "mod-a," "mod-b," and "master-copy."
2. In "mod-a," modify a.
3. In "mod-b," create a different file (b).
4. Merge (--no-ff) "mod-a" onto master.
5. Amend the merge with a modification to a.
6. Merge (--no-ff) "mod-b" onto "master-copy."
7. Rebase -p master onto "master-copy."
Notice the change to "a" from step #5 is now gone. "a" reverts to the pre-amended version after step #4.
I assume this isn't expected behavior and is a bug.