arenaq
arenaq

Reputation: 2380

How to rebase feature branch from theme branch to development branch?

We have development branch, from which feature branches emerge. Some features are big enough they becomes a topic branches. These topic branches then have more sub-branches that are merged into topic branch and after all topic is finished, then it is merged to development.

Now, I started feature branch from topic branch, but I should have started from development. How can I rebase this?

development
A--B--C--D--E--F--G
       \
topic   T1----------T2--T3--T4--T5
         \         /          \
          U1--U2--U3           W1--W2--W3
         sub-feature U         feature W`

Feature W should have started from development branch.

Is there a way to rebase commits W1, W2 and W3 onto a development branch without touching topic branch T?

I know I could checkout development branch and cherry pick each commit, but that would create a new commit with new metadata. I want to keep commit creation date and perhaps author!

Upvotes: 1

Views: 58

Answers (1)

VonC
VonC

Reputation: 1323273

You can make a rebase --onto:

git rebase --committer-date-is-author-date --onto dev T4 W`

That will replay any commit after T4, up to and including W HEAD, onto the dev branch.

                     W1'--W2'--W3' (W)
                    /
A--B--C--D--E--F--G (dev)
       \
topic   T1----------T2--T3--T4--T5
         \         /         
          U1--U2--U3           
         sub-feature U        

See "git rebase without changing commit timestamps", as a workaround to keep a sensible commit date.
But any rebase will always change the metadata.

Upvotes: 3

Related Questions