{"thread":{"id":"15838","subject":"Really remove a file ?","startedAt":"2008-10-09T18:12:28Z","lastAt":"2008-10-10T20:50:00Z","messageCount":6,"participants":["marcreddist@aim.com","Alex Riesen","Stefan Karpinski","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92691","messageId":"8CAF851B91FEF07-660-20E9@webmail-da15.sysops.aol.com","threadId":"15838","inReplyTo":null,"subject":"Really remove a file ?","fromName":"","fromEmail":"marcreddist@aim.com","sentAt":"2008-10-09T18:12:28Z","receivedAt":"2008-10-09T18:12:28Z","isPatch":false,"sender":{"key":"marcreddist@aim.com","avatar":null},"body":"Hi,\n\n\n\n\n\nI'm a new git user for some weeks or so and well i think git is \nawesome. I didn't read all the online docs and mans yet, but i'm \nalready really impressed by it's power. Thanks everyone for this \nhelpful tool.\n\n\n\nRight now i think i need some help. I started to work for a project, \nand everything went fine. But I noticed someone placed a huge data file \nin the repository. This file shouldn't have been here at the first \nplace. So I deleted it with git-rm. But that wasn't clever because now, \n\"git log -p\" or \"git log -S'something'\" are really really slow. Also \ndiffs are huge and lots of command results are hard to read.\n\n\n\nSo is there a way to really remove a file in the git repository so that \nit never existed (I mean not having the diff in the logs and the data \nstored somewhere in the .git directory) ? Or if it's not the was git is \nsupposed to be used, is there a way to hide the diff (even from \ngit-log) or something ?\n\n\n\n\n\nThank you again,\n\n--\n\nMarc R.\n"},{"id":"92692","messageId":"81b0412b0810091156v15dea27an95050a06cfb4f8df@mail.gmail.com","threadId":"15838","inReplyTo":"8CAF851B91FEF07-660-20E9@webmail-da15.sysops.aol.com","subject":"Re: Really remove a file ?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-10-09T18:56:35Z","receivedAt":"2008-10-09T18:56:35Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2008/10/9  <marcreddist@aim.com>:\n> So is there a way to really remove a file in the git repository so that it\n> never existed (I mean not having the diff in the logs and the data stored\n> somewhere in the .git directory) ? Or if it's not the was git is supposed to\n> be used, is there a way to hide the diff (even from git-log) or something ?\n\nYes. But you'll change the whole history (of course, it should _never_\nmention the file).\nSee git filter-branch (there is even an example at the end of its man page.\nReplace mv with rm)\n"},{"id":"92724","messageId":"d4bc1a2a0810091643u3903a1f4h44d3579b98fe6922@mail.gmail.com","threadId":"15838","inReplyTo":"81b0412b0810091156v15dea27an95050a06cfb4f8df@mail.gmail.com","subject":"Re: Really remove a file ?","fromName":"Stefan Karpinski","fromEmail":"stefan.karpinski@gmail.com","sentAt":"2008-10-09T23:43:11Z","receivedAt":"2008-10-09T23:43:11Z","isPatch":false,"sender":{"key":"stefan.karpinski@gmail.com","avatar":"https://gravatar.com/avatar/780cfb8dd7d7dc749d7276a4ca2ec24e7f0482cfce509717c5ddd165fd2cc9d9?d=mp&s=160"},"body":"Specifically, you probably want to do something like this:\n\n  $ git filter-branch --index-filter 'git update-index --remove\n<filename>' --force -- --all\n\nBeware that this will make your repository effectively \"incompatible\"\nwith those of others who've pulled from you before—because all of your\nhistory is now completely rewritten. You should probably have them\nclone a new copy from the repo you've run this on instead of trying to\ncontinue working with their old repos. Otherwise all hell breaks\nloose. You'll probably also want to run \"git gc\" on your repo to\nactually get rid of the huge object that was added (or does\nfilter-branch do this automatically?).\n\nOn Thu, Oct 9, 2008 at 11:56 AM, Alex Riesen <raa.lkml@gmail.com> wrote:\n>\n> 2008/10/9  <marcreddist@aim.com>:\n> > So is there a way to really remove a file in the git repository so that it\n> > never existed (I mean not having the diff in the logs and the data stored\n> > somewhere in the .git directory) ? Or if it's not the was git is supposed to\n> > be used, is there a way to hide the diff (even from git-log) or something ?\n>\n> Yes. But you'll change the whole history (of course, it should _never_\n> mention the file).\n> See git filter-branch (there is even an example at the end of its man page.\n> Replace mv with rm)\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"92739","messageId":"8CAF8D313562BEE-1588-259E@webmail-da15.sysops.aol.com","threadId":"15838","inReplyTo":"d4bc1a2a0810091643u3903a1f4h44d3579b98fe6922@mail.gmail.com","subject":"Re: Really remove a file ?","fromName":"","fromEmail":"marcreddist@aim.com","sentAt":"2008-10-10T09:38:25Z","receivedAt":"2008-10-10T09:38:25Z","isPatch":false,"sender":{"key":"marcreddist@aim.com","avatar":null},"body":"Hi,\n\n\n\nThank you both, that's exactly what i needed.\n\n\n\nIn case someone finds this post in the future, this :\n\n> $ git filter-branch --index-filter 'git update-index --remove\n\n' --force -- --all\n\nworked perfectly. Although, it told me that git can't work on a dirty \ndirectory so I did this :\n\n$ git add .\n\n$ git commit\n\nAnd after the filter-branch\n\n$ git reset --hard HEAD^\n\n\n\n> You'll probably also want to run \"git gc\" on your repo to\n\n> actually get rid of the huge object that was added (or does\n\n> filter-branch do this automatically?).\n\nI'm not sure it's required by git-filter-branch alone. In this case :\n\ngit-gc saves almost 5% after the file deletion\n\nit saves 4.5% before the file deletion\n\nIf I run git gc before and after the git filter-branch, it saves 4.5% \nand then 0.2%.\n\n\n\nBut maybe my tests applies to my particular environment and cannot be \ngeneralized.\n\n\n\n\n\nThank you again for the help.\n\nTake care,\n\nMarc, happy git user.\n\n\n\n-- \n"},{"id":"92755","messageId":"20081010143249.GE3671@atjola.homenet","threadId":"15838","inReplyTo":"8CAF8D313562BEE-1588-259E@webmail-da15.sysops.aol.com","subject":"Re: Really remove a file ?","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-10-10T14:32:49Z","receivedAt":"2008-10-10T14:32:49Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.10.10 05:38:25 -0400, marcreddist@aim.com wrote:\n>> You'll probably also want to run \"git gc\" on your repo to actually\n>> get rid of the huge object that was added (or does filter-branch do\n>> this automatically?).\n>\n> I'm not sure it's required by git-filter-branch alone. In this case :\n>\n> git-gc saves almost 5% after the file deletion\n>\n> it saves 4.5% before the file deletion\n>\n> If I run git gc before and after the git filter-branch, it saves 4.5%  \n> and then 0.2%.\n\nDid you clear the refs/original namespace and your reflogs? Otherwise,\nthe huge object is most likely still referenced and thus won't get\npruned. Also, I usually prefer \"git repack -adf\" over \"git gc\" in such\nsituations, but that's probably just because I don't know the right\nway to force \"git gc\" to immediately prune stuff just once.\n\nBut don't do the pruning until you're absolutely sure that you don't\nrequire the old stuff anymore.\n\nBjörn\n"},{"id":"92773","messageId":"d4bc1a2a0810101350h17856074qfe397078b734eb85@mail.gmail.com","threadId":"15838","inReplyTo":"20081010143249.GE3671@atjola.homenet","subject":"Re: Really remove a file ?","fromName":"Stefan Karpinski","fromEmail":"stefan.karpinski@gmail.com","sentAt":"2008-10-10T20:50:00Z","receivedAt":"2008-10-10T20:50:00Z","isPatch":false,"sender":{"key":"stefan.karpinski@gmail.com","avatar":"https://gravatar.com/avatar/780cfb8dd7d7dc749d7276a4ca2ec24e7f0482cfce509717c5ddd165fd2cc9d9?d=mp&s=160"},"body":"> But don't do the pruning until you're absolutely sure that you don't\n> require the old stuff anymore.\n\nOr, of course, you could just keep an independent copy of the whole\nrepo pre-filter-branch.\n\nOn Fri, Oct 10, 2008 at 7:32 AM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n>\n> On 2008.10.10 05:38:25 -0400, marcreddist@aim.com wrote:\n> >> You'll probably also want to run \"git gc\" on your repo to actually\n> >> get rid of the huge object that was added (or does filter-branch do\n> >> this automatically?).\n> >\n> > I'm not sure it's required by git-filter-branch alone. In this case :\n> >\n> > git-gc saves almost 5% after the file deletion\n> >\n> > it saves 4.5% before the file deletion\n> >\n> > If I run git gc before and after the git filter-branch, it saves 4.5%\n> > and then 0.2%.\n>\n> Did you clear the refs/original namespace and your reflogs? Otherwise,\n> the huge object is most likely still referenced and thus won't get\n> pruned. Also, I usually prefer \"git repack -adf\" over \"git gc\" in such\n> situations, but that's probably just because I don't know the right\n> way to force \"git gc\" to immediately prune stuff just once.\n>\n> But don't do the pruning until you're absolutely sure that you don't\n> require the old stuff anymore.\n>\n> Björn\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}