After merging a branch into master, I realized that I ideally should have made a minor commit before the branch was merged, because it is directly related to the commit before the merge. I have tried to clarify what the desired outcome looks like in the simplified example below, where
- B is the merge commit of X and Y into master,
- C is a commit that relates to the merged content,
- D does not touch any of the newly merged content and is directly related to A.
Current branch structure:
A----B-C-D
/
X-Y
The desired outcome is to move D right after A, while leaving the rest as is:
A-D----B-C
/
X-Y
Rebase after picking all commits and moving D after A:
A-D-X-Y-B-C
Rebase after dropping X and Y, and moving D after A:
A-D-B-C
How can I keep the branch in my history? Is rebase the wrong tool here? I have looked at cherry-pick, but I am not sure how I would use it to achieve the desired outcome.
In case it matters, the branch did not origin from master, but from an unrelated repo. It added a couple of new files while retaining their commit history from the previous repo. This is for a local repo where I am the only contributor.