Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3314372
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:13:30+00:00 2026-05-17T22:13:30+00:00

My organisation is preparing to release an open-source version of our software using github,

  • 0

My organisation is preparing to release an open-source version of our software using github, however I’m not sure the best way to approach this:

We have two branches master and release, master contains some proprietary components that we have decided not to release, and release contains the cleaned-up version that we want to distribute. The problem is, if we just push the release branch to github, the proprietary components can be retrieved by looking through the revision history.

I was considering creating a separate repository, copying the HEAD of relase into it, doing a git init, and pushing that repository to github. However, we want to retain the ability to cherry-pick certain patches from master into release in the future, and push those changes up to github.

Is there a way to do this without maintaining two separte repositories?

Thanks!

Update:

To be a little more specific, this is sort-of what our commit history looks like at the moment:

--- o - o - o - o - f - o - o - f - master
             \
              c - c - c - c - c - c - c - REL - f - f

Where ‘o’ are commits in the master, proprietary branch, ‘c’ are commits that remove things that should not be published (often not removing entire files, but reworking existing ones not to rely on proprietary components), and ‘f’ are fixes in master that apply to release as well, and so have been cherry-picked. REL is a tagged version of the code we deem safe to publish, with no history whatsoever (even previous versions of the release branch, since not all the proprietary material had been removed before the REL tag).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:13:30+00:00Added an answer on May 17, 2026 at 10:13 pm

    Ben Jackson’s answer already covers the general idea, but I’d like to add a few notes (more than a comment’s worth) about the ultimate goal here.

    You can quite easily have two branches, one with an entirely clean (no private files) history, and one complete (with the private files), and share content appropriately. The key is to be careful about how you merge. An oversimplified history might look something like this:

    o - o - o - o - o - o - o (public)
     \       \           \   \
      x ----- x ----x---- x - x (private)
    

    The o commits are the “clean” ones, and the x are the ones containing some private information. As long as you merge from public to private, they can both have all the desired shared content, without ever leaking anything. As Ben said, you do need to be careful about this – you can’t ever merge the other way. Still, it’s quite possible to avoid – and you don’t have to limit yourself to cherry-picking. You can use your normal desired merge workflow.

    In reality, your workflow could end up a little more complex, of course. You could develop a topic (feature/bugfix) on its own branch, then merge it into both the public and the private versions. You could even cherry-pick now and then. Really, anything goes, with the key exception of merging private into public.

    filter-branch

    So, your problem right now is simply getting your repository into this state. Unfortunately, this can be pretty tricky. Assuming that some commits exist which touch both private and public files, I believe that the simplest method is to use filter-branch to create the public (clean) version:

    git branch public master   # create the public branch from current master
    git filter-branch --tree-filter ... -- public    # filter it (remove private files with a tree filter)
    

    then create a temporary private-only branch, containing only the private content:

    git branch private-temp master
    git filter-branch --tree-filter ... -- private-temp    # remove public files
    

    And finally, create the private branch. If you’re okay with only having one complete version, you can simply merge once:

    git branch private private-temp
    git merge public
    

    That’ll get you a history with only one merge:

    o - o - o - o - o - o - o - o - o - o (public)
                                         \
      x -- x -- x -- x -- x -- x -- x --- x (private)
    

    Note: there are two separate root commits here. That’s a little weird; if you want to avoid it, you can use git rebase --root --onto <SHA1> to transplant the entire private-temp branch onto some ancestor of the public branch.

    If you’d like to have some intermediate complete versions, you can do the exact same thing, just stopping here and there to merge and rebase:

    git checkout -b private <private-SHA1>  # use the SHA1 of the first ancestor of private-temp
                                            # you want to merge something from public into
    git merge <public-SHA1>           # merge a corresponding commit of the public branch
    git rebase private private-temp   # rebase private-temp to include the merge
    git checkout private
    git merge <private-SHA1>          # use the next SHA1 on private-temp you want to merge into
                                      # this is a fast-forward merge
    git merge <public-SHA1>           # merge something from public
    git rebase private private-temp   # and so on and so on...
    

    This will get you a history something like this:

    o - o - o - o - o - o - o - o - o - o (public)
          \              \               \
      x -- x -- x -- x -- x -- x -- x --- x (private)
    

    Again, if you want them to have a common ancestor, you can do an initial git rebase --root --onto ... to get started.

    Note: if you have merges in your history already, you’ll want to use the -p option on any rebases to preserve the merges.

    fake it

    Edit: If reworking the history really turns out to be intractable, you can always totally fudge it: squash the entire history down to one commit, on top of the same root commit you already have. Something like this:

    git checkout public
    git reset --soft <root SHA1>
    git commit
    

    So you’ll end up with this:

    o - A' (public)
     \
      o - x - o - x - X - A (public@{1}, the previous position of public)
                   \
                    x - x (private)
    

    where A and A' contain exactly the same content, and X is the commit in which you removed all private content from the public branch.

    At this point, you can do a single merge of public into private, and from then on, follow the workflow that I described at the top of the answer:

    git checkout private
    git merge -s ours public
    

    The -s ours tells git to use the “ours” merge strategy. This means it keeps all content exactly as it is in the private branch, and simply records a merge commit showing that you merged the public branch into it. This prevents git from ever applying those “remove private” changes from commit X to the private branch.

    If the root commit has private information in it, then you’ll probably want to create a new root commit, instead of committing once on top of the current one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the pros and cons of adopting Open Source software for an organisation?
If our organisation were to switch from a central-server VCS like subversion to a
I am working on a Web based organisation tool. I am not aiming the
I have developed a framework that is used by several teams in our organisation.
Introduction In my current organisation, we have many desktop and web applications all feeding
We are an organisation who have purchased a system which is used by doctors
Someone left the organisation but before leaving, he locked all the files for an
I provide a web service to my organisation. i was wondering would anyone recommeding
I've been searching for a library that can render organisation charts in either flash
I am struggling to make a decision regarding the correct organisation for a web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.