{"thread":{"id":"23687","subject":"how to delete the entire history before a certain commit","startedAt":"2010-05-03T22:23:55Z","lastAt":"2010-05-03T23:58:20Z","messageCount":5,"participants":["Gelonida","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"140856","messageId":"hrnidr$etm$1@dough.gmane.org","threadId":"23687","inReplyTo":null,"subject":"how to delete the entire history before a certain commit","fromName":"Gelonida","fromEmail":"gelonida@gmail.com","sentAt":"2010-05-03T22:23:55Z","receivedAt":"2010-05-03T22:23:55Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"Hi,\n\nI noticed, that this post never arrived :-( . So here again.\n\n\n\nWe have a git repository, whose size we want to reduce drastically due\nto frequent clone operations and a slow network connection.\n\n\nThe idea is following:\n\n* archive the git repository just in case we really have to go back in\nhistory.\n\n\ncreate a new git repository, which shall only contain last month's activity.\n\nall changes before should be squashed together.\nIt would be no problem if the very first commit remains unmodified.\n\n\nI made some attempts with\ngit rebase -i\n\n\nbut I always encounter errors.\nExample error is a cherry pick which can't be applied.\n\n\nIs git rebase the correct way to delete en entire history section or are\nthere smarter ways to do this? (e.g. create a new repository with last\nmonths state as starting point and some 'magic' to replay from this\npoint on with all branches and merges_\n\n\n\nthanks for any suggestion.\n"},{"id":"140859","messageId":"m3ocgwfvw2.fsf@localhost.localdomain","threadId":"23687","inReplyTo":"hrnidr$etm$1@dough.gmane.org","subject":"Re: how to delete the entire history before a certain commit","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-05-03T22:45:01Z","receivedAt":"2010-05-03T22:45:01Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Gelonida <gelonida@gmail.com> writes:\n\n> We have a git repository, whose size we want to reduce drastically due\n> to frequent clone operations and a slow network connection.\n \nWhy frequent *clone* operations, instead of using \"git fetch\" or\nequivalent (\"git pull\" which is fetch+merge, or \"git remote update\")?\n\nIf network is slow, you can do what others did in similar situations:\nuse hook to allow only not to large fetches (to prevent cloning)\ndirectly on server, and provide bundle (see git-bundle(1)) to \"seed\"\nthe clone; it can be on dumb server (served resumably), and can be\nalso served by BitTorrent or equivalent.\n \n> The idea is following:\n> \n> * archive the git repository just in case we really have to go back in\n> history.\n> \n> \n> create a new git repository, which shall only contain last month's activity.\n> \n> all changes before should be squashed together.\n> It would be no problem if the very first commit remains unmodified.\n\nIf you want to simply _remove_ history before specified commit,\ninstead of squashing it, the best solution would be to use grafts to\ncauterize (cut) history, check using [graphical] history viewer that\nyou cut it correctly, and then then use git-filter-branch to make this\ncut permanent.\n\nYou can later use grafts or refs/replaces/ mechanism to join \"current\"\nhistory with historical repository.\n\nHTH.\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"140861","messageId":"hrnl7o$nnf$1@dough.gmane.org","threadId":"23687","inReplyTo":"m3ocgwfvw2.fsf@localhost.localdomain","subject":"Re: how to delete the entire history before a certain commit","fromName":"Gelonida","fromEmail":"gelonida@gmail.com","sentAt":"2010-05-03T23:11:52Z","receivedAt":"2010-05-03T23:11:52Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"Hi Jakub,\n\nJakub Narebski wrote:\n> Gelonida <gelonida@gmail.com> writes:\n> \n>> We have a git repository, whose size we want to reduce drastically due\n>> to frequent clone operations and a slow network connection.\n>  \n> Why frequent *clone* operations, instead of using \"git fetch\" or\n> equivalent (\"git pull\" which is fetch+merge, or \"git remote update\")?\n\nThe clone is part of the deployment process and would IIRC be equivalent\nto a 'svn export'\nAlmost certainly one can also improve this, but this should probably\ndiscussed in another thread.\n\nThe sequence on some remote hosts is.\n- git clone tag dirname\n- rm -rf dirname/.git\n- tar cvfz dirname.tgz dirname\n\n\n> \n> If network is slow, you can do what others did in similar situations:\n> use hook to allow only not to large fetches (to prevent cloning)\n\n\n> directly on server, and provide bundle (see git-bundle(1)) to \"seed\"\n> the clone; it can be on dumb server (served resumably), and can be\n> also served by BitTorrent or equivalent.\nThe server NW is fast, but the clients' network connection not therefore\nno need to offload the server.\n>  \n>> The idea is following:\n>>\n>> * archive the git repository just in case we really have to go back in\n>> history.\n>>\n>>\n>> create a new git repository, which shall only contain last month's activity.\n>>\n>> all changes before should be squashed together.\n>> It would be no problem if the very first commit remains unmodified.\n> \n> If you want to simply _remove_ history before specified commit,\n> instead of squashing it, the best solution would be to use grafts to\n> cauterize (cut) history, check using [graphical] history viewer that\n> you cut it correctly, and then then use git-filter-branch to make this\n> cut permanent.\n\nThis sounds exactly as what I'd like to do.\nI used \"git gui\" => \"Visualize All Branch History\" y to choose a nice\nsingle cutoff point.\nI just didn't know how to apply the cut.\n\nSo the command to look for is git-filter-branch, right ?\nI'll read the doc.\n\n> \n> You can later use grafts or refs/replaces/ mechanism to join \"current\"\n> history with historical repository.\n\nProbably we wont need this, but this sounds rather interesting and is\ngood to know.\n\n\n\nThanks a lot\n"},{"id":"140866","messageId":"m3k4rkft7k.fsf@localhost.localdomain","threadId":"23687","inReplyTo":"hrnl7o$nnf$1@dough.gmane.org","subject":"Re: how to delete the entire history before a certain commit","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-05-03T23:42:58Z","receivedAt":"2010-05-03T23:42:58Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Gelonida <gelonida@gmail.com> writes:\n> Jakub Narebski wrote:\n>> Gelonida <gelonida@gmail.com> writes:\n>> \n>>> We have a git repository, whose size we want to reduce drastically due\n>>> to frequent clone operations and a slow network connection.\n>>  \n>> Why frequent *clone* operations, instead of using \"git fetch\" or\n>> equivalent (\"git pull\" which is fetch+merge, or \"git remote update\")?\n> \n> The clone is part of the deployment process and would IIRC be equivalent\n> to a 'svn export'\n> Almost certainly one can also improve this, but this should probably\n> discussed in another thread.\n> \n> The sequence on some remote hosts is.\n> - git clone tag dirname\n> - rm -rf dirname/.git\n> - tar cvfz dirname.tgz dirname\n \nWhy not simply (after enabling 'upload-archive' service in git-daemon\nif you serve via git:// URL, and probably similar in the case of\nSSH access management by gitosis or gitolite)\n\n  $ git archive --remote=<repo> <tag>\n\n(where <repo> is <dirname> in your example)?\n\n>>> The idea is following:\n>>>\n>>> * archive the git repository just in case we really have to go back in\n>>> history.\n>>>\n>>>\n>>> create a new git repository, which shall only contain last month's activity.\n>>>\n>>> all changes before should be squashed together.\n>>> It would be no problem if the very first commit remains unmodified.\n>> \n>> If you want to simply _remove_ history before specified commit,\n>> instead of squashing it, the best solution would be to use grafts to\n>> cauterize (cut) history, check using [graphical] history viewer that\n>> you cut it correctly, and then then use git-filter-branch to make this\n>> cut permanent.\n> \n> This sounds exactly as what I'd like to do.\n> I used \"git gui\" => \"Visualize All Branch History\" y to choose a nice\n> single cutoff point.\n> I just didn't know how to apply the cut.\n\nYou can read about grafts in git-filter-branch(1) manpage, in\ngitrepository-layout(5) git repository layout description, and in\ngitglossary(7) a git glossary.\n\nIn short, each line in .git/info/grafts consist of sha1 id of object,\nfollowed by space-separated list of its effective (grafted) parents.\nSo to cut history e.g. after commit a3eb250f996bf5e, you need to put\nline containing only this SHA-1 in .git/info/grafts file, e.g.:\n\n  $ git rev-parse --verify a3eb250f996bf5e >> .git/info/grafts\n \n> So the command to look for is git-filter-branch, right ?\n> I'll read the doc.\n\n\nAs you would see in git-filter-branch(1) documentation, simple\n\n  $ git filter-branch --all\n\n(no filter) would make history described by grafts permanent.\n\nNote that this will be rewriting history, and you would make it (much)\nharder on any contributor who based his/her work on commits from\nbefore \"rebase\".\n \n>> \n>> You can later use grafts or refs/replaces/ mechanism to join \"current\"\n>> history with historical repository.\n> \n> Probably we wont need this, but this sounds rather interesting and is\n> good to know.\n\nGrafts were for example used to fuse (join) current and historical\nLinux kernel repositories, after Linux kernel moved from BitKeeper to\nGit.\n\nThe 'git-replace' mechanism is meant as modern, transferable and safe\nreplacements for grafts file.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"140868","messageId":"4BDF631C.8010800@gmail.com","threadId":"23687","inReplyTo":"m3k4rkft7k.fsf@localhost.localdomain","subject":"Re: how to delete the entire history before a certain commit","fromName":"Gelonida","fromEmail":"gelonida@gmail.com","sentAt":"2010-05-03T23:58:20Z","receivedAt":"2010-05-03T23:58:20Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"Hi Jakub,\n\nJakub Narebski wrote:\n> Gelonida <gelonida@gmail.com> writes:\n>> Jakub Narebski wrote:\n>>> Gelonida <gelonida@gmail.com> writes:\n>>>\n>>>> We have a git repository, whose size we want to reduce drastically \n\n\n>>> If you want to simply _remove_ history before specified commit,\n>>> instead of squashing it, the best solution would be to use grafts to\n>>> cauterize (cut) history, check using [graphical] history viewer that\n>>> you cut it correctly, and then then use git-filter-branch to make this\n>>> cut permanent.\n\n> You can read about grafts in git-filter-branch(1) manpage, in\n> gitrepository-layout(5) git repository layout description, and in\n> gitglossary(7) a git glossary.\n> \n> In short, each line in .git/info/grafts consist of sha1 id of object,\n> followed by space-separated list of its effective (grafted) parents.\n> So to cut history e.g. after commit a3eb250f996bf5e, you need to put\n> line containing only this SHA-1 in .git/info/grafts file, e.g.:\n> \n>   $ git rev-parse --verify a3eb250f996bf5e >> .git/info/grafts\n>  \n>> So the command to look for is git-filter-branch, right ?\n>> I'll read the doc.\n> \n> \n> As you would see in git-filter-branch(1) documentation, simple\n> \n>   $ git filter-branch --all\n\n\nThe command\ngit filter-branch --all\ndid not work for me. it just fdisplays the help text.\n\nhowever without '--all'\ngit filter-branch\n\nseems to have worked.\n\nThanks a lot :-)\n"}]}