gitversion-controlmergegit-branchgit-flow

Merge changed files from feature to a hotfix git flow


I have 3 branches

develop, master and a feature branch which is made with git flow feature start.

Now I want to make the commits which are made from the feature to be merged into a separate hotfix so I can merge it into the master without merging the developer branch into the master how can I do that?

To clerify

develop has 100+ commits which are made for a separate release,

I made branch out of the dev, and want to make it into a separate hotfix.

The problem is a hotix is a master originating branch, so if I do git merge feature git will merge ALL of the developer commits with the few commits I amde on the feature.

The question is. how to cherry pick the feature?

EDIT:

@Pigueiras

I am more like in this situation, I draw a diagram. enter image description here

I need to ONLY transfer the red noted commits from the feature to the hotfix.


Solution

  • It seems like you want to use a rebase --onto. In the git documentation you have an example about how to move the parent of the branch that you are using.

    In your case, you should do:

    git rebase --onto hotfix develop feature/branch
    

    Also related: Setting git parent pointer to a different parent.

    Be aware that this is a rebase, so don't do that if the commits are published for more developers.