I'm working on a project with Git and have come to a point where I'd like to break development into two separate branches. The split concerns a simple Change (with a capital C so I can refer back to it later) that affects one isolated part of the codebase -- in one branch, I want the Change to be present; in the other, I don't. The Change is encapsulated in one commit.
The master
branch, which is where I do all my coding (unless a specific topic comes up) is the branch that I want to contain the Change. I'd like to make a separate branch, original
(or whatever you want to call it), that does not contain the Change.
master
, the branch with the Change, will remain the primary, preferred branch: that's the branch I'll keep coding on and that's the branch whose code I'll actually run. I want to keep original
around just in case I need a version of the code without the aforementioned Change later.
Here's the problem: I'd like to be able to "merge" work from master
into original
down the road, but, obviously, only the commits that don't concern the Change.
- If I do a simple
git merge master
,original
will fast-forward tomaster
, introducing the Change I didn't want, right? - I don't want to develop on
original
and merge tomaster
, becauseoriginal
is the special case, notmaster
. - I don't want to
cherry-pick
frommaster
, because that's going to muddy up my development history. - I could make a new branch,
develop
, from the commit that introduces the Change inmaster
. I could make non-Change-related commits on this branch and easily merge them intomaster
ororiginal
. However, if I make some Change-related commits onmaster
and want to merge them intodevelop
, then I'll again be unable to safely mergedevelop
intooriginal
, right?
I'd like to know your opinions on how best to proceed.
EDIT: I'm the only person working on this project, so don't rule out a solution because it may mess up other programmers in a collaborative setting. I'm just looking for an easy-to-use solution that produces a clean, intuitive history that captures what these different development histories really are. If no such solution exists, I'll accept one of the answers that get the job done.