The current project I'm working on, I am trying to explore a bunch of different ideas which usually manifest themselves as a bunch of feature branches. The features I'm working on are generally orthogonal to one another, so there are times when I want to merge all of these features (or some subset of the features) and test them out together.
So far my workflow has been this -- I have branches featureA
, featureB
, featureC
and I'll have a branch called featureA_featureB
and then another one like featureA_featureB_featureC
, etc.
I am having 2 problems:
featureC
, but since I'm in the featureA_featureC
branch, I accidentally commit to this branch instead (I really need to stop using git commit -a
). Then I have to cherry pick the commit or do some other crazy stuff to get the commit to the right place.Thanks in advance!
Merge branchesMerging your branch into master is the most common way to do this. Git creates a new commit (M) that is referred to as a merge commit that results from combining the changes from your feature branch and master from the point where the two branches diverged.
When you're done with a branch and it has been merged into master, delete it. A new branch can be made off of the most recent commit on the master branch. Also, while it is ok to hang onto branches after you've merged them into the master they will begin to pile up.
Build your strategy from these three concepts: Use feature branches for all new features and bug fixes. Merge feature branches into the main branch using pull requests. Keep a high quality, up-to-date main branch.
I was going to write an answer of my own, but then I found this great answer (and a great question). It does not give you a single way to do things, but upon a careful reading, you should be able to find a workflow that suits your situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With