Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I manage multiple development branches in Git?

Tags:

git

branch

I have 5 branches of one system - let's call them master, London, Birmingham, Manchester and demo. These differ in only a configuration file and each has its own set of graphics files.

When I do some development, I create a temp branch from master, called after the feature, and work on that. When ready to merge I checkout master, and git merge feature to bring in my work. That appears to work just fine.

Now I need to get my changes into the other branches, without losing the differences between them that are there already. How can I do that? I have been having no end of problems with Birmingham getting London's graphics, and with conflicts within the configuration file.

When the branch is finally correct, I push it up to a depot, and pull each branch down to a Linux box for final testing, From there the release into production is using rsync (set to ignore the .git repository itself). This phase works just fine also.

I am the only developer at the moment, but I need to get the process solid before inviting assistance :)

like image 655
Ian Avatar asked May 24 '10 11:05

Ian


1 Answers

Two techniques can help:

  • submodules: if you have 5 "mains projects", each one composed of:
    • the common code (which get enhanced feature after feature)
    • the special code (specif graphic files or config values, one set for each site)
  • template config files

So when you develop a new feature, all you need to do for the other sites to benefit from it is to make sure their respective repo reference the latest common code repo as a submodule. Just a git submodule update to do and you are done.

Plus, with template config files, all you are storing are config values, not the actual config files themselves (they get generated).
That allows you some fine-tuning on each site, without having to "ignore" local modifications.

In conclusion: instead of trying to manage all aspects (common code, config files, special files, ...) in one repo (with all the merge and rebase that will involve), try to modularize your application.

like image 102
VonC Avatar answered Oct 23 '22 11:10

VonC