tags:

views:

69

answers:

1

Background: I'm in the process of cleaning up a project before releasing it as open-source. During the code history there's been a bunch of things I don't really want to show up in a public repository (swearing in comments, hardcoded paths, embarrassing pieces of code), so I only want the public to see the code base after the cleanup cut-off point - yet I want to retain full history in my own private repository.

After the cutoff point the private and public repositories are going to be kept entirely in sync. Apart from local non-pushed temporary branches, there won't be any private branches; the master branch on both repositories should be identical, except the public history is chopped at the cut-off point.

As far as I can tell Git requires repositories having full history, so I can't directly push my local master branch to both the public and private repositories. I guess it would be possible creating a separate 'public' branch and using history rewriting, but this would require merging the private branch to the public before pushing code to the repositories - I'd like a setup that requires as little manual work as possible.

The public repository is intended to be pull-only, with me doing integration. The private repository will be hosted on my own linux server, so it would be possible to set up commit hooks that auto-merge to a different (public) repo and then push to the public repo. I hope there's a cleaner solution, though - there's probably a way to structure this that I haven't thought of.

Thanks in advance for any suggestions :)

Update 1

Trying to follow VonC's recommendation, this is what I've got so far:

Assumptions: Private repository is cleaned up, committed locally, and pushed to git@server:private.git . Public repository created with files from last private commit, is committed locally, and pushed to git@server:public.git .

1) ~/priv$ git remote add public git@server:public.git 2) ~/priv$ git fetch public

warning: no common commits (stuff snipped) * [new branch] master -> public/master

3) ~/priv$ git log --format='%H %s'

d2d66cf2861ac7136ee3dc04467781825413b084 Cleaned up code base, ready for public! 9ba0ccf4c819eb85dbe4613caec959b04edfb39a Commit #2 a37c3c645dcdc4d8e5fc7ef3c53727cbf1d903ad First (private) commit.

The top hash (d2d66...) is the private head commit.

4) ~/priv$ git log --reverse --format='%H %s' public/master

090a335746ecb03ea5362909be4969b87a99ab80 First public commit! c43fccdda05319e57498f4f517650f9edbdb942a Second public commit :)

Because of --reverse, the oldest hash (090a3...) is at top.

5) ~/priv$ echo '090a335746ecb03ea5362909be4969b87a99ab80 d2d66cf2861ac7136ee3dc04467781825413b084' >> .git/info/grafts

At this point, git log public/master shows revisionist history, but I'm unsure how to progress wrt. filter-branch and all that... I've only succeeded in messing things up :)

+2  A: 

Once you have done your cleanup, you can create a new repo with only one commit (the "clean" one"), which you will push to your public repo.

Except that locally, you will have two repos:

VonC
Sorry for the late reply, missed your answer >_<. I'm afraid I'm almost completely lost; I'd really appreciate a hand-holding step-by-step guide, if you have the time :). Assuming I'm at the point where private codebase is cleaned up, commited, and pushed to remote-priv and a bare remote-pub has been set up - what do I do? Also, should the mission succeed, I assume all further development continues in the public repo, but the old private repo can show full history?
snemarch
@snemarch: the idea remains to 1/ go on with the development on the new and small cleaned-up repo (that you can keep in sync with the public remote one), 2/ but also graft it when needed to your private repo in order to get the full history there.
VonC
@VonC: I've updated the question to show what I've attempted - I'm unsure how to progress from there. Hopefully, with a little help, this can be turned into a for-dummies guide ;)
snemarch