Eric Lee
Eric Lee

Reputation: 8989

Git workflow for maintaining an project extension fork?

We've forked an OSS project on GitHub and are adding some custom extensions to it. We'll want to send some of the changes we make back to the original project (bug fixes and the like) but other changes are feature extensions that the original project maintainers aren't interested in at the moment. I'm trying to figure out the best workflow for managing this situation.

I want our master branch to contain the sum of (commits from the original project) + (our bug fixes for contribution) + (our custom extensions). I imagine we'll want a branch-per-feature model so that we can keep bug fixes separate from custom extensions. We can start custom extension branches from our master branch, but I guess we'll also want to maintain a local "origin" branch or something that tracks the original project so that we can start bugfix branches from there that aren't polluted with our custom stuff. Or something.

Can anyone suggest the best way to structure this workflow such that all the various commits go where they're supposed to go and none go where they're not supposed to go?

Upvotes: 14

Views: 993

Answers (2)

aleroot
aleroot

Reputation: 72626

What you want to setup is a long term fork, to do this as you already figured out the solution could be setting up a special branch linked with the original "vanilla" project and have a master branch where you maintain your custom working copy.

The only thing that you have to keep in mind (from my point of view) is that you shouldn't merge the two branch when you want to synch changes, but in this case (When Branches Diverge) there is the handy Git Cherry-Pick command that lets you take a single commit from one branch and apply it to another, this could be particularly useful in the case of maintaining a fork because you can easily exchange single commit from one branch to another ...

Upvotes: 1

kini
kini

Reputation: 1803

It sounds to me like you have already answered your own question. Create a branch called "vanilla" or something which tracks upstream's master branch, and have a "master" branch which contains your custom extensions. Create branches for each thing you do. For bugfixes, start them off of "vanilla". For your own stuff, start them off of master. Every once in a while, merge vanilla into master. To get the bugfixes into your custom extensions branch, you could merge their branches into master directly, or just wait for upstream to accept your bugfix pull requests, and then the next merge from vanilla to master would contain the bugfixes. This seems like a very normal workflow.

Upvotes: 7

Related Questions