Recently the devteam for Make a Good Mega Man Level 2 switched from GameMaker 8.1 to Game Maker: Studio, which, in addition to allowing git to be used for continued development, had the unfortunate side effect of introducing long compilation times due to the very large size of the project, in particular setting up texture pages. To help facilitate quick development, one of the devs, Ren, had the idea of creating a branch with all the large parts of the game removed.
Right away though, there was a problem making this work with git. If we forked the
master branch into a
lightweight branch and removed certain files, then later when merging back into
master, those files would again be deleted as the removal commit entered
The red circle represents the commit where large assets were intentionally deleted
So, to make it easier to merge features from the lightweight development branch into master, I had the idea of first removing the heavy-weight assets in a commit in master, branching from that point into
lightweight, and on master reverting the changes with another commit. The is quite simple; the command
git revert, unlike
git reset, creates a new commit which undoes the effect of a previous commit.
The red circle represents the commit where large assets were intentionally deleted, and the teal circle represents the inverse of that commit
This solves the problem most of the time, since most devs will primarily be merging from lightweight into master. But sometimes somebody will edit master directly and the lightweight branch will need to be updated. In order to do this, instead of using
git merge master from the lightweight branch, which will bring in the
revert commit that undid the removal of the heavyweight assets, we can use
git cherry-pick to duplicate the new commits from
master that aren’t already in the
lightweight branch. To automatically pull in all these commits, one can tag the
revert commit (it being the earliest commit that we don’t want to bring in) as something like
heavy (since it brings in heavyweight assets`), and use this command:
git cherry-pick heavy..master
This applies all the commits between
and the tip of master
(inclusive) to the current branch (lightweight`). Conveniently, it also skips commits that have already been brought in.