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.

  • Prepend Git commit message with partial branch name
  • Is there an inverse to Git's octopus merge?
  • Getting Beyond Compare to Diff 2 Branches Simultaneously
  • How to make existing git branch track a remote branch?
  • Configure TeamCity to build from SVN trunk, branches and/or tags
  • Where to store differences between dev and production branch in git?
  • 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.

  • Git ignore local changes to portions of tracked files
  • Undoing temporary changes with Git
  • Libgit2Sharp: get files in all commits between two tags
  • Impossible to git rm with special characters
  • Git - Make local HEAD the new master
  • Can't switch branches - “Error: Untracked working tree files…” should I do git add?
  • 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.