{"thread":{"id":"35056","subject":"Using filter-branch without messing up the working copy","startedAt":"2013-10-03T15:07:09Z","lastAt":"2013-10-03T15:07:09Z","messageCount":1,"participants":["Dale R. Worley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"228534","messageId":"201310031507.r93F79ci003282@hobgoblin.ariadne.com","threadId":"35056","inReplyTo":null,"subject":"Using filter-branch without messing up the working copy","fromName":"Dale R. Worley","fromEmail":"worley@alum.mit.edu","sentAt":"2013-10-03T15:07:09Z","receivedAt":"2013-10-03T15:07:09Z","isPatch":false,"sender":{"key":"worley@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/19911107?v=4"},"body":"I'm working on using \"git filter-branch\" to remove the history of a\nlarge file from my repository so as to reduce the size of the\nrepository.  This pattern of use is effective for me:\n\n1. $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch core.4563' HEAD\n\n2. edit .git/packed-refs to remove the line\n   \"c6589bef2c776277407686a3a81c5a76bfe41ba2 refs/original/refs/heads/hobgoblin\"\n(so that there is no reference to the old HEAD)\n\n3. git gc --quiet --aggressive\n\nThe difficulty I am having is that I do not want to disturb the\nworking copy while doing this.  The working copy is my entire home\ndirectory, because I am using the repository as a historical backup\nsystem for my home directory.  Currently, Git will not execute\nfilter-branch if there are unstaged changes in the working copy,\ndespite the fact that \"git filter-branch --index-filter\" does not\ntouch the working copy itself.  (In this case, the file to be deleted,\n\"core.4563\", is not now in the working copy.)\n\nA further difficulty is that the repository is \"remote\", the .git\ndirectory is not in my home directory, and core.worktree is\n\"/home/worley\".\n\nThe best set of steps I have found that accomplishes my goals is to\n(1) \"disconnect\" the repository from the working copy by removing the\ncore.worktree value, (2) use \"git checkout -q -f master\" to create in\nthe repository's location an entire copy of my home directory, (3)\nperform the above filtering steps, (4) \"reconnect\" the repository by\nadding the core.worktree value, and (5) deleting the temporary working\ncopy files.\n\nSurely there is a better way than this.\n\nDale\n"}]}