using git to maintain a shared codebase

I’m not quite sure what the right terminology is to use for this, so please forgive me in advance if I munge things horribly.

I currently maintain a codebase in git for an app that I publish in the Mac app store. For various reasons, I am now looking at publishing a non-MAS release as well.

  • Can't see remote branch, problems with .git/config?
  • SVN Mergeinfo properties on paths other than the working copy root
  • mysterious vanishing branches in git
  • git branch merging details
  • Git: get the list of branches into which current branch was ever merged
  • Track all remote git branches as local branches
  • Obviously, the MAS and non-MAS releases will share 95% of a common code base. In fact, about the only parts they will not share in common will be receipt checking (MAS release), and license keys + auto-updates (non-MAS release).

    This brings me to the gist of my question – presumably the “right” way to do this would be to maintain two separate branches in git? How can I easily make sure the two branches stay in sync without worrying about bleeding the receipt checking and license key code between the two versions? What about xcode project management? Suppose I add a file to the MAS project, is there an easy way to make it show up in the non MAS project?

    Please let me know if any clarification is needed.

    Thanks in advance.

  • Changing git commit message after push (given that no one pulled from remote)
  • How to pull from a different remote branch in git
  • How can i configure font size in gitk?
  • How to Do a Complicated Git Repository Merger?
  • Possible Ways to refer a commit
  • Doing a three-way compare with Git and KDiff3
  • 2 Solutions collect form web for “using git to maintain a shared codebase”

    I wouldn’t use different branches, you would want version 2.0 for the MAS and version 2.0 for the non-MAS to be feature equivalent as much as possible. I would just have two Targets and define MAC_APP_STORE=1 in the debug and release configuration for the MAS target. 95% of the code will be members of both targets but the license and auto update code files would only be members of the non-MAS target. There will be a few bits in the common code that need to be conditionally compiled like this:

    #ifdef MAC_APP_STORE

    If you can isolate the different files in one sub-directory, then you could consider working with a submodule (see the Pro Git book chapter on it)

    That way:

    • you only have one branch to maintain for the parent repo which contains the 95% common code
    • you can maintain branches for the files specific to a given release in the submodule repo.
    Git Baby is a git and github fan, let's start git clone.