When I create a new branch, do some commits and then merge the branche back to master, I get only one new commit in the main branch which contains all the changes from all commits. Is there a way of merging, where the commits are duplicated into the master branch?
Example:
A -- B -- C
\
D -- E -- F
I want to merge C to F, so that I get the following:
A -- B -- C
\
D -- B' -- E' -- C' -- F'
Or another diagram that shows the same:
A -- B ---- C
\ \ \
D ----- E ----- F
To do that, it would have to modify EVERY SINGLE COMMIT from F back to D, and add the modified versions of the commits I want to merge in. In the end, I wouldn´t get a new commit at all, I would only change very much commits.
Is there something that can achieve such a behavior?
You can use
git cherry-pickto duplicate commits into another branch. There is alsogit rebasewhich may or may not be more suitable for your task.Note that your second graph shows a state that isn’t called a merge even if you call it so.