How to change the basis of a branch?

Asked

Viewed 147 times

4

I have a branch derived from master, development, that never comes back to master. All the branchs of features are derivatives of development, but after tested and validated, are combined both with the development when with the master. I can’t match directly to development with the master because I have features there that are not yet to be merged with the master.

I wonder if there’s any way to change the base branch of a feature without causing conflicts in the files that were not changed only in this feature.

Today I can do the git cherry-pick <commit> but I believe that on a tree with many commits is a bit of a hassle.

The design of my flows branchs is more or less the following:

                                   .-[feature1]---o---o---o-.
                                  /                          \
                                 /   .-[feature2]---o-.       \
                                /   /                  \       \
             .-[development]---´---´--------------------+-------+
            /                                            \       \
[master]---´----------------------------------------------+-------+---...

o - commits                    + - merge

In the above drawing, today, what would be the merge I’m doing like cherry-pick.

  • 2

    I don’t think that’s an ideal answer, but git cherry-pick A^..B makes the Cherry-pick of all commits between A to B (including commits A and B themselves)

  • @hkotsubo but the problem is that it will catch from all branchs who have commit at that time, no?

  • 1

    If it’s the way it is in the picture, I don’t think so. If all commits between A and B belong to the Feature1 branch, you’ll only get these.

  • @hkotsubo then, but not the case, because the development of the feature1 and feature2 occur in parallel. It occurred to me now that maybe I can give squash in the pull request by putting in development and then do the cherry-pick only of merge. I don’t know if I can do this

  • 1

    Yeah, I don’t know either. I usually use git in a more "basic" way (branch -> push -> pull request), once in a while I do a Cherry-pick or rebase here and there, but that’s it. I do not do many "juggling", let alone suggest that others do it. Sorry I can not help more...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.