Consider that I have two branches: master
and staging
. Commit C
was made on staging
and cherry-picked into master
urgently, so it's already there.
-x-x-x-A-B-C-D (staging)
/
-x-x-x-C (master)
Later, another branch feature
was merged directly into master
, so two commits were added to master
, the commit E
and the merge commit F
.
-x-x-x-A-B-C-D (staging)
/
-x-x-x-C-E-F (master)
I need to get what is in master
into staging
to get a clean merge of staging
into master
. I end up with duplicate commits because of the cherry-pick if I just use merges. If I rebase instead: git checkout staging && git rebase origin/master
I get A
, B
, and D
on top (although, I don't think the merge commit F
comes in unless I use --rebase-merges
, could be wrong though):
-x-x-x-C-E-F-A-B-D (staging)
But what if I wanted those three commits to be merged in based on when they were actually created and end up with:
-x-x-x-A-B-C-D-E-F (staging)
Is this possible and does it make sense at all to do this? Or am I better off putting A
, B
, and D
on top?
Here are what I believe are the relevant parts of the result for git log --graph master
. I added the commit letters I used in the question after each commit hash.
* commit c0ead31e3f7a7f6e077b2bbb947775dcd2dc3453 (**F**) (HEAD -> master, origin/master, origin/HEAD)
|\ Merge: b943c0fd 07a7dd24
| | Author: Author
| | Date: Tue Nov 22 03:23:09 2022 +0000
| |
| | Merge branch 'feature' into 'master'
| |
| | <commit message for feature>
| |
| | See merge request company/project!24
| |
| * commit 07a7dd245bec741e1c077d055558b3930c570a3f (**E**)
|/ Author: Author
| Date: Tue Nov 22 03:20:57 2022 +0000
|
| <commit message for feature>
|
* commit b943c0fd70e5ba64b70b03721ab2962facaecbc3 (**C**)
| Author: Author
| Date: Wed Oct 19 18:49:58 2022 +0000
|
| <commit message>
|
|
| (cherry picked from commit e1598f670d0e78e76ee0e54a4a4668e7186adbab)
|