1

I was hoping to get some ideas. I have three branches:

  • master
  • specific
  • feature-branch

master contains the generic code base so that if I want to branch out later to create a new type of implementation, I can easily do so. But for now specific is my main development branch.

So I branched specific off into feature-branch to test a new feature, once I was satisfied I merged feature-branch back into specific.

But there are some commits which are implementation specific in specific which I don't want to merge back into master. Most of the code is generic changes, which I do want to merge back.

I merged about 30 changes from feature-branch into specific. Of those 30, probably about 20 I want to merge from specific into master.

What is the best way for me to do this?

Should I just cherry pick each of the commits I want to merge into master? If so, should I just go in reverse chronological order (ie. get the oldest commit I want to merge in, then the second oldest, and so on - cherry picking them all back into master).

Any ideas are welcome. Thanks

b85411
  • 9,420
  • 15
  • 65
  • 119

1 Answers1

1

It is best (if you haven't pushed specific to any remote repo yet) to:

  • reorder your commits in the specific branch (the one for master, then the implementation-specific one), with an interactive rebase.
  • merge only the 20 first commits to master (that will be a fast-forward merge)
    You can create a temporary branch on the most recent of those 20 commits (git branch tmp SHA1), and merge that branch (git checkout master ; git merge tmp)

That way, no cherry-picking, meaning no duplication of commits.


If specific has been pushed, then cherry-picking can work, starting from the older to the newest commit.

In the "cherry-pick A..B" form, A should be older than B. If they're the wrong order the command will silently fail.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250