orangejulius
orangejulius

Reputation: 1029

Best practices for git repositories on open source projects

I'm contributing to a fairly small open source project hosted on Github. So that other people can take advantage of my work, I've created my own fork on Github. Despite Github's choice of terminology, I don't wish to totally diverge from the main project. However, I don't expect or desire that all of my work is accepted into the main repository. Some of it however, already has been merged into the main repository and I expect this to continue. The problem I am running into is how best to keep our two trees in a state where code can be shared between them easily.

Some situations I have or will encountered include:

As far as I can tell there are two, or possibly three ways to handle this, none of which work particularly well:

What have other people done in this situation? I know my situation is analogous to the relationship between various kernel contributors and Linus's main repository, so hopefully there are good ways to handle this. I'm fairly new to git though, so haven't mastered all it's nuances. Finally, especially due to Github, my terminology may not be entirely consistent or correct. Feel free to correct me.

Upvotes: 35

Views: 3157

Answers (1)

sykloid
sykloid

Reputation: 101206

Some tips I've learned from a similar situation:

  • Have a remote tracking branch for the upstream author's work.
  • Pull changes from this tracking branch into your master branch every so often.
  • Create a new branch for each of the topics you're working on. These branches should generally be local only. When you get changes from upstream into master, rebase your topic branches to reflect these changes.
  • When you're done with some topic work, merge into master. This way, people who are deriving work from yours, will not see too much rewritten history, since the rebasing occurred in your local topic branches.
  • Submitting changes: Your master branch will basically be a series of commits, some of which are the same as upstream, the rest are yours. The latter can be sent as patches if you want to.

Of course, your choice of branch names and remotes are your own. I'm not sure these are exhaustive to the scenario, but they cover most of my hurdles.

Upvotes: 19

Related Questions