Skip to content

Instantly share code, notes, and snippets.

@daaronr
Last active January 27, 2022 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daaronr/50ae70031cbd1500ff51e46ebd0cd441 to your computer and use it in GitHub Desktop.
Save daaronr/50ae70031cbd1500ff51e46ebd0cd441 to your computer and use it in GitHub Desktop.

Git/Github Question I keep coming back to

  • I need to maintain 2 versions of a page, site, or report, for different audiences. E.g., one ‘public’ and one ‘private within group’

  • I keep each of these on distinct branches in the same repository

  • Alternatively I could make these separate repositories, one fork in the other, although that feels more bulky

  • I frequently want to compare the contents of each of these versions, moving content in both directions, but inspecting the content before I move it over

What I’ve tried/explored

  1. Cherry pick individual commits from one branch to the other
  • this is good when the commit history is very careful and concise, but it doesn’t work when I have hundreds of commits, or when you only want material from part of a commit and not the whole commit
  1. Pull request from one branch to another
  • but here I can’t figure out how to say “selectively introduced content” in an efficient way
  1. Checkout individual files from a branch or manually move them from one branch to my hard drive and then do a manual comparison using vim’s spliutdiff.
  • This works but it’s tedious and feels like working around rather than with git and github
  1. Git diff individual files between branches into a new file, and sort out changes e.g., git diff make_publicable..main SUMMARY.md > SUMMARY_MERGE.md
  • but this leads to an output of a git diff file that I don’t have a handy and quick tool to reconcile. I can’t get it to come up as the Atom ‘your version’ ‘their version’ thing, for example

Any thoughts appreciated? Any tools or techniques I’m missing, or things I should read?

Suggestions and going-forward

Better commits and then you can cherrypick

DHJ: Maybe cherry pick commits and use git squash to make your commit history more coherent? DR: Yeah, in principle, when on the Private branch I should separate my 'content commits' into ones labeled 'content_for_public_too' and 'private_content'.

GH actions, 'hosted only'

DHJ: Or could you just produce an output and host that somewhere in public Eg using GitHub actions

DR: I need to learn GH actions. But I kind of need to allow people to add content to both versions (insiders can add to and view the private version, outsiders only the public version ... and then I need to decide which stuff should move from one to the other)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment