{"thread":{"id":"22442","subject":"Partially private repository?","startedAt":"2010-01-29T22:01:50Z","lastAt":"2010-02-01T08:20:47Z","messageCount":4,"participants":["Daed Lee","Avery Pennarun","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133021","messageId":"78d8a6b51001291401ib93976el25c03694d53aaced@mail.gmail.com","threadId":"22442","inReplyTo":null,"subject":"Partially private repository?","fromName":"Daed Lee","fromEmail":"daed@thoughtsofcode.com","sentAt":"2010-01-29T22:01:50Z","receivedAt":"2010-01-29T22:01:50Z","isPatch":false,"sender":{"key":"daed@thoughtsofcode.com","avatar":null},"body":"Hi, I'm wondering if git can handle the following use. I have a\nproject that started as private experiment, but has morphed into\nsomething I'd like to release publicly. I want to give others access\nto the repository, but only to commits after a certain cutoff date.\nCommits prior to that date have things like hardcoded file paths,\nemails, etc. that I'd like to keep private.\n\nI suppose the easiest thing to do would be to create a new repository,\nadd the project files to it, and make that public, however I'd like to\nkeep my private commit history along with the public commit history\ngoing forward in a single repository if possible. Is there a way to do\nthis with git?\n\nAppreciate any pointers in the right direction. Thanks.\n"},{"id":"133024","messageId":"32541b131001291410g252ddff4lbf04ac7c1d2d33fc@mail.gmail.com","threadId":"22442","inReplyTo":"78d8a6b51001291401ib93976el25c03694d53aaced@mail.gmail.com","subject":"Re: Partially private repository?","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-01-29T22:10:53Z","receivedAt":"2010-01-29T22:10:53Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Fri, Jan 29, 2010 at 5:01 PM, Daed Lee <daed@thoughtsofcode.com> wrote:\n> Hi, I'm wondering if git can handle the following use. I have a\n> project that started as private experiment, but has morphed into\n> something I'd like to release publicly. I want to give others access\n> to the repository, but only to commits after a certain cutoff date.\n> Commits prior to that date have things like hardcoded file paths,\n> emails, etc. that I'd like to keep private.\n>\n> I suppose the easiest thing to do would be to create a new repository,\n> add the project files to it, and make that public, however I'd like to\n> keep my private commit history along with the public commit history\n> going forward in a single repository if possible. Is there a way to do\n> this with git?\n\nYou should probably split your history into two pieces: the \"before\"\nand \"after\" parts.  To split out the \"after\" part, you could use\ngit-filter-branch\n(http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.6/git-filter-branch.html).\n Then, in your private copy of the repo, you could reattach the\n\"before\" part of the history using git grafts.\n\nHave fun,\n\nAvery\n"},{"id":"133218","messageId":"78d8a6b51001312059s1811b631y838679a3f63188b0@mail.gmail.com","threadId":"22442","inReplyTo":"32541b131001291410g252ddff4lbf04ac7c1d2d33fc@mail.gmail.com","subject":"Re: Partially private repository?","fromName":"Daed Lee","fromEmail":"daed@thoughtsofcode.com","sentAt":"2010-02-01T04:59:00Z","receivedAt":"2010-02-01T04:59:00Z","isPatch":false,"sender":{"key":"daed@thoughtsofcode.com","avatar":null},"body":"On Fri, Jan 29, 2010 at 5:10 PM, Avery Pennarun <apenwarr@gmail.com> wrote:\n> On Fri, Jan 29, 2010 at 5:01 PM, Daed Lee <daed@thoughtsofcode.com> wrote:\n>> Hi, I'm wondering if git can handle the following use. I have a\n>> project that started as private experiment, but has morphed into\n>> something I'd like to release publicly. I want to give others access\n>> to the repository, but only to commits after a certain cutoff date.\n>> Commits prior to that date have things like hardcoded file paths,\n>> emails, etc. that I'd like to keep private.\n>>\n>> I suppose the easiest thing to do would be to create a new repository,\n>> add the project files to it, and make that public, however I'd like to\n>> keep my private commit history along with the public commit history\n>> going forward in a single repository if possible. Is there a way to do\n>> this with git?\n>\n> You should probably split your history into two pieces: the \"before\"\n> and \"after\" parts.  To split out the \"after\" part, you could use\n> git-filter-branch\n> (http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.6/git-filter-branch.html).\n>  Then, in your private copy of the repo, you could reattach the\n> \"before\" part of the history using git grafts.\n\nGoing forward, if I made changes to my private repository (containing\nthe \"before\" and \"after\" parts) and pushed to the public repository\n(containing only the \"after\" part), would this only push the commits\nin the \"after\" part? Essentially, I want to develop in my private\nrepository and see my \"before\" and \"after\" changes when I \"git\nlog/show\", but only push the \"after\" changes to the public repository.\n\nI've also been looking into private branches. Could I do something\nlike keep my \"before\" changes on a private branch, and then do all\nfuture development on a public branch?\n\nThanks for the pointer to git grafts, I'll have to read up on it further.\n"},{"id":"133231","messageId":"4B668EDF.5030409@viscovery.net","threadId":"22442","inReplyTo":"78d8a6b51001312059s1811b631y838679a3f63188b0@mail.gmail.com","subject":"Re: Partially private repository?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-02-01T08:20:47Z","receivedAt":"2010-02-01T08:20:47Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Daed Lee schrieb:\n> On Fri, Jan 29, 2010 at 5:10 PM, Avery Pennarun <apenwarr@gmail.com> wrote:\n>> On Fri, Jan 29, 2010 at 5:01 PM, Daed Lee <daed@thoughtsofcode.com> wrote:\n>>> Hi, I'm wondering if git can handle the following use. I have a\n>>> project that started as private experiment, but has morphed into\n>>> something I'd like to release publicly. I want to give others access\n>>> to the repository, but only to commits after a certain cutoff date.\n>>> Commits prior to that date have things like hardcoded file paths,\n>>> emails, etc. that I'd like to keep private.\n>>>\n>>> I suppose the easiest thing to do would be to create a new repository,\n>>> add the project files to it, and make that public, however I'd like to\n>>> keep my private commit history along with the public commit history\n>>> going forward in a single repository if possible. Is there a way to do\n>>> this with git?\n>> You should probably split your history into two pieces: the \"before\"\n>> and \"after\" parts.  To split out the \"after\" part, you could use\n>> git-filter-branch\n>> (http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.6/git-filter-branch.html).\n\nSidenote: http://www.kernel.org/pub/software/scm/git/docs/git.html is the\nmost up-to-date version with pointers to older versions. The page for\nfilter-branch has an example how to prune history with grafts.\n\n>>  Then, in your private copy of the repo, you could reattach the\n>> \"before\" part of the history using git grafts.\n\nThat is, you use grafts twice: Once to split off the \"after\" part, again\nto re-attach it locally.\n\n> Going forward, if I made changes to my private repository (containing\n> the \"before\" and \"after\" parts) and pushed to the public repository\n> (containing only the \"after\" part), would this only push the commits\n> in the \"after\" part? Essentially, I want to develop in my private\n> repository and see my \"before\" and \"after\" changes when I \"git\n> log/show\", but only push the \"after\" changes to the public repository.\n\nThe thing is that grafts are an old mechanism, and they do not always do\nthe right thing. In particular, when you push the \"after\" part that you\nhave spliced with the \"before\" part using a graft, then the objects in the\n\"before\" part will be pushed as well. But since the remote repository does\nnot have the graft, these objects are inaccessible - *except* when offer\naccess via dumb protocols (rsync or dumb http).\n\nThere is a newer mechanism: 'git replace'. It does the right thing. That\nis, after you have split the \"before\" and \"after\" parts (using a graft and\nfilter-branch), you splice them together using 'git replace'.\n\nHere is a recipe that should do it (not tested, try it on a clone):\n\n--- 8< ---\n# interesting commits\nfirst_after=first-commit-of-the-after-part  # all 40 digits!\nbefore=$first_after^\ngit tag first-after $first_after\n\n# split using a graft\necho $first_after > .git/info/grafts\ngit filter-branch --tag-name-filter=cat -- --all --not $before\n\n# reattach\ngit replace first-after $first_after\n--- 8< ---\n\nWe know that the old $first_after has the right parenthood that we need to\nre-attach the split histories. We tag $first_after, and make sure the tag\ngets rewritten. Then we can use the tag name in the 'git replace' call:\nThe tag name points to the rewritten (parentless) commit, and $first_after\nis the old commit whose parent points to \"before\".\n\n> I've also been looking into private branches. Could I do something\n> like keep my \"before\" changes on a private branch, and then do all\n> future development on a public branch?\n\nYou can, and you *must* do that, i.e., you must have a branch (or tag)\nthat points to the last commit on the \"before\" part. Otherwise, it is all\ntoo easy to garbage-collect this part.\n\nBut you must make sure that you never merge a private branch into the\npublic history.\n\n-- Hannes\n"}]}