4

following scenario: i have multiple branches (master/preview/release). i am developing in master, doing periodic commits. let's call them "experimental" and "fixes".

now i want to merge selected fixes-commits to my preview-branch without the experimantal-commits.

the image should show what i mean.

schema of git-repository

now i tried it with cherry-pick and rebase but i didn't figure out how to manage that.

tienbuiDE
  • 183
  • 4
  • 13
  • Firstly - 'i am developing in master', oh god. Secondly, how are you doing a cherry pick? That should be as simple as checking out the branch you wish to add the changes to and running a cherry-pick with the hash of your desired commit. – nav May 14 '12 at 08:47
  • fistly: it's just a scenario to easily explain what i want to do :O secondly: i am doing the cherry-pick as following: `git checkout preview` and then `git cherry-pick hashcode` where hashcode is the hashcode of the `ADC`-commit. as expected my file looks like that afterwards: `A <<<<<<< HEAD B ======= D C >>>>>>> bbd71e0... ADC ` – tienbuiDE May 14 '12 at 08:50
  • There is nothing inherently special about the master branch, I don't see why you shouldn't develop there - it might not fit *your* model of development, but there is nothing immediately bad about it. Of course, it might be a good idea to commit the bugfixes in a different branch from the experimental new features - then you can just merge the bugfix branch into the experimental branch to keep things synced. – Medo42 May 14 '12 at 08:55
  • The way you're doing it sounds good. What's the matter exactly ? Got an error ? – Yanflea May 14 '12 at 09:14

1 Answers1

1

It looks like cherry-pick is the tool you want, but from your comments it is apparent that you get a conflict. In that case, read the output of the git cherry-pick command carefully, it should tell you how to proceed in order to complete the cherry-pick. Generally, you have to find the conflicting files (using e.g. git status), resolve the conflicts, and then git add the resolved files. These three steps can also be replaced by using git mergetool. When you are done resolving, you can use git cherry-pick --continue to finish the operation.

You might want to think about your branch model though, generally you should not need to use cherry-pick often. Consider e.g. developing features in their own branches and merging them into the appropriate "release branches" (preview/release) when preparing a new version for those.

Medo42
  • 3,821
  • 1
  • 21
  • 37