dineth
dineth

Reputation: 9942

git merge only changeset

I have an interesting problem, I can't seem to find a simple enough answer for this. I have 3 tracked branches: master, staging, production. Master is the main code that I play with and merge changes to. Staging is identical to my heroku staging server setup and production is the same case as staging.

After some reading around the internet (misplaced my bookmark to the beanstalk article), a nice way to work on changes is to branch from master, do a whole bunch of changes while committing regularly. Then this feature branch is merged into master, which gets tested on my dev machine.

Then the tricky bit, the feature-branch should be merged to staging branch which then gets pushed to heroku. If staging tests succeeds, I want to merge feature-branch to production as well.

Simple enough. The tricky part is really the fact that I have slight different setups on each branch. Master has some SSL stuff turned off etc. Staging has a few different certificates etc. Production has some newrelic tracking etc.

Doing a git merge seems to override my settings all the time. This is such a pain. I have been cherry-picking or git checkout <file list> to merge inidividual changes. Is there a way to go: "Merge all the commits (change-set) from the feature-branch into Staging branch", without bringing all the other stuff along?

Upvotes: 1

Views: 386

Answers (1)

VonC
VonC

Reputation: 1324023

If you go the cherry-pick route, you can use the git-extract-patches, if you have good commit message (ie a commit message you can parse in order to select the commit for export).

Note that cherry-picking has some drawbacks (duplication and functional dependencies), but if you don't merge back Staging to feature-branch, it is ok.

Note also that, for single files that varry between branches, a content filter driver can also be another solution (avoiding any merge issue).
See as an example "Different versions of the same configuration file in different branches".

Upvotes: 1

Related Questions