Autogenerated HTML docs for v1.6.5
[git/jnareb-git.git] / git-filter-branch.html
blob101067694892b95322c597cf27d7b70d0ed2ae21
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-filter-branch(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-filter-branch(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-filter-branch -
317 Rewrite branches
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="verseblock">
324 <div class="content"><em>git filter-branch</em> [--env-filter &lt;command&gt;] [--tree-filter &lt;command&gt;]
325 [--index-filter &lt;command&gt;] [--parent-filter &lt;command&gt;]
326 [--msg-filter &lt;command&gt;] [--commit-filter &lt;command&gt;]
327 [--tag-name-filter &lt;command&gt;] [--subdirectory-filter &lt;directory&gt;]
328 [--prune-empty]
329 [--original &lt;namespace&gt;] [-d &lt;directory&gt;] [-f | --force]
330 [--] [&lt;rev-list options&gt;&#8230;]</div></div>
331 </div>
332 <h2 id="_description">DESCRIPTION</h2>
333 <div class="sectionbody">
334 <div class="para"><p>Lets you rewrite git revision history by rewriting the branches mentioned
335 in the &lt;rev-list options&gt;, applying custom filters on each revision.
336 Those filters can modify each tree (e.g. removing a file or running
337 a perl rewrite on all files) or information about each commit.
338 Otherwise, all information (including original commit times or merge
339 information) will be preserved.</p></div>
340 <div class="para"><p>The command will only rewrite the _positive_ refs mentioned in the
341 command line (e.g. if you pass <em>a..b</em>, only <em>b</em> will be rewritten).
342 If you specify no filters, the commits will be recommitted without any
343 changes, which would normally have no effect. Nevertheless, this may be
344 useful in the future for compensating for some git bugs or such,
345 therefore such a usage is permitted.</p></div>
346 <div class="para"><p><strong>NOTE</strong>: This command honors <tt>.git/info/grafts</tt>. If you have any grafts
347 defined, running this command will make them permanent.</p></div>
348 <div class="para"><p><strong>WARNING</strong>! The rewritten history will have different object names for all
349 the objects and will not converge with the original branch. You will not
350 be able to easily push and distribute the rewritten branch on top of the
351 original branch. Please do not use this command if you do not know the
352 full implications, and avoid using it anyway, if a simple single commit
353 would suffice to fix your problem. (See the "RECOVERING FROM UPSTREAM
354 REBASE" section in <a href="git-rebase.html">git-rebase(1)</a> for further information about
355 rewriting published history.)</p></div>
356 <div class="para"><p>Always verify that the rewritten version is correct: The original refs,
357 if different from the rewritten ones, will be stored in the namespace
358 <em>refs/original/</em>.</p></div>
359 <div class="para"><p>Note that since this operation is very I/O expensive, it might
360 be a good idea to redirect the temporary directory off-disk with the
361 <em>-d</em> option, e.g. on tmpfs. Reportedly the speedup is very noticeable.</p></div>
362 <h3 id="_filters">Filters</h3><div style="clear:left"></div>
363 <div class="para"><p>The filters are applied in the order as listed below. The &lt;command&gt;
364 argument is always evaluated in the shell context using the <em>eval</em> command
365 (with the notable exception of the commit filter, for technical reasons).
366 Prior to that, the $GIT_COMMIT environment variable will be set to contain
367 the id of the commit being rewritten. Also, GIT_AUTHOR_NAME,
368 GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
369 and GIT_COMMITTER_DATE are set according to the current commit. The values
370 of these variables after the filters have run, are used for the new commit.
371 If any evaluation of &lt;command&gt; returns a non-zero exit status, the whole
372 operation will be aborted.</p></div>
373 <div class="para"><p>A <em>map</em> function is available that takes an "original sha1 id" argument
374 and outputs a "rewritten sha1 id" if the commit has been already
375 rewritten, and "original sha1 id" otherwise; the <em>map</em> function can
376 return several ids on separate lines if your commit filter emitted
377 multiple commits.</p></div>
378 </div>
379 <h2 id="_options">OPTIONS</h2>
380 <div class="sectionbody">
381 <div class="vlist"><dl>
382 <dt>
383 --env-filter &lt;command&gt;
384 </dt>
385 <dd>
387 This filter may be used if you only need to modify the environment
388 in which the commit will be performed. Specifically, you might
389 want to rewrite the author/committer name/email/time environment
390 variables (see <a href="git-commit.html">git-commit(1)</a> for details). Do not forget
391 to re-export the variables.
392 </p>
393 </dd>
394 <dt>
395 --tree-filter &lt;command&gt;
396 </dt>
397 <dd>
399 This is the filter for rewriting the tree and its contents.
400 The argument is evaluated in shell with the working
401 directory set to the root of the checked out tree. The new tree
402 is then used as-is (new files are auto-added, disappeared files
403 are auto-removed - neither .gitignore files nor any other ignore
404 rules <strong>HAVE ANY EFFECT</strong>!).
405 </p>
406 </dd>
407 <dt>
408 --index-filter &lt;command&gt;
409 </dt>
410 <dd>
412 This is the filter for rewriting the index. It is similar to the
413 tree filter but does not check out the tree, which makes it much
414 faster. Frequently used with <tt>git rm --cached
415 --ignore-unmatch &#8230;</tt>, see EXAMPLES below. For hairy
416 cases, see <a href="git-update-index.html">git-update-index(1)</a>.
417 </p>
418 </dd>
419 <dt>
420 --parent-filter &lt;command&gt;
421 </dt>
422 <dd>
424 This is the filter for rewriting the commit's parent list.
425 It will receive the parent string on stdin and shall output
426 the new parent string on stdout. The parent string is in
427 the format described in <a href="git-commit-tree.html">git-commit-tree(1)</a>: empty for
428 the initial commit, "-p parent" for a normal commit and
429 "-p parent1 -p parent2 -p parent3 &#8230;" for a merge commit.
430 </p>
431 </dd>
432 <dt>
433 --msg-filter &lt;command&gt;
434 </dt>
435 <dd>
437 This is the filter for rewriting the commit messages.
438 The argument is evaluated in the shell with the original
439 commit message on standard input; its standard output is
440 used as the new commit message.
441 </p>
442 </dd>
443 <dt>
444 --commit-filter &lt;command&gt;
445 </dt>
446 <dd>
448 This is the filter for performing the commit.
449 If this filter is specified, it will be called instead of the
450 <em>git-commit-tree</em> command, with arguments of the form
451 "&lt;TREE_ID&gt; [-p &lt;PARENT_COMMIT_ID&gt;]&#8230;" and the log message on
452 stdin. The commit id is expected on stdout.
453 </p>
454 <div class="para"><p>As a special extension, the commit filter may emit multiple
455 commit ids; in that case, the rewritten children of the original commit will
456 have all of them as parents.</p></div>
457 <div class="para"><p>You can use the <em>map</em> convenience function in this filter, and other
458 convenience functions, too. For example, calling <em>skip_commit "$@"</em>
459 will leave out the current commit (but not its changes! If you want
460 that, use <em>git-rebase</em> instead).</p></div>
461 <div class="para"><p>You can also use the <em>git_commit_non_empty_tree "$@"</em> instead of
462 <em>git commit-tree "$@"</em> if you don't wish to keep commits with a single parent
463 and that makes no change to the tree.</p></div>
464 </dd>
465 <dt>
466 --tag-name-filter &lt;command&gt;
467 </dt>
468 <dd>
470 This is the filter for rewriting tag names. When passed,
471 it will be called for every tag ref that points to a rewritten
472 object (or to a tag object which points to a rewritten object).
473 The original tag name is passed via standard input, and the new
474 tag name is expected on standard output.
475 </p>
476 <div class="para"><p>The original tags are not deleted, but can be overwritten;
477 use "--tag-name-filter cat" to simply update the tags. In this
478 case, be very careful and make sure you have the old tags
479 backed up in case the conversion has run afoul.</p></div>
480 <div class="para"><p>Nearly proper rewriting of tag objects is supported. If the tag has
481 a message attached, a new tag object will be created with the same message,
482 author, and timestamp. If the tag has a signature attached, the
483 signature will be stripped. It is by definition impossible to preserve
484 signatures. The reason this is "nearly" proper, is because ideally if
485 the tag did not change (points to the same object, has the same name, etc.)
486 it should retain any signature. That is not the case, signatures will always
487 be removed, buyer beware. There is also no support for changing the
488 author or timestamp (or the tag message for that matter). Tags which point
489 to other tags will be rewritten to point to the underlying commit.</p></div>
490 </dd>
491 <dt>
492 --subdirectory-filter &lt;directory&gt;
493 </dt>
494 <dd>
496 Only look at the history which touches the given subdirectory.
497 The result will contain that directory (and only that) as its
498 project root.
499 </p>
500 </dd>
501 <dt>
502 --prune-empty
503 </dt>
504 <dd>
506 Some kind of filters will generate empty commits, that left the tree
507 untouched. This switch allow git-filter-branch to ignore such
508 commits. Though, this switch only applies for commits that have one
509 and only one parent, it will hence keep merges points. Also, this
510 option is not compatible with the use of <em>--commit-filter</em>. Though you
511 just need to use the function <em>git_commit_non_empty_tree "$@"</em> instead
512 of the <em>git commit-tree "$@"</em> idiom in your commit filter to make that
513 happen.
514 </p>
515 </dd>
516 <dt>
517 --original &lt;namespace&gt;
518 </dt>
519 <dd>
521 Use this option to set the namespace where the original commits
522 will be stored. The default value is <em>refs/original</em>.
523 </p>
524 </dd>
525 <dt>
526 -d &lt;directory&gt;
527 </dt>
528 <dd>
530 Use this option to set the path to the temporary directory used for
531 rewriting. When applying a tree filter, the command needs to
532 temporarily check out the tree to some directory, which may consume
533 considerable space in case of large projects. By default it
534 does this in the <em>.git-rewrite/</em> directory but you can override
535 that choice by this parameter.
536 </p>
537 </dd>
538 <dt>
540 </dt>
541 <dt>
542 --force
543 </dt>
544 <dd>
546 <em>git-filter-branch</em> refuses to start with an existing temporary
547 directory or when there are already refs starting with
548 <em>refs/original/</em>, unless forced.
549 </p>
550 </dd>
551 <dt>
552 &lt;rev-list options&gt;&#8230;
553 </dt>
554 <dd>
556 Arguments for <em>git-rev-list</em>. All positive refs included by
557 these options are rewritten. You may also specify options
558 such as <em>--all</em>, but you must use <em>--</em> to separate them from
559 the <em>git-filter-branch</em> options.
560 </p>
561 </dd>
562 </dl></div>
563 </div>
564 <h2 id="_examples">Examples</h2>
565 <div class="sectionbody">
566 <div class="para"><p>Suppose you want to remove a file (containing confidential information
567 or copyright violation) from all commits:</p></div>
568 <div class="listingblock">
569 <div class="content">
570 <pre><tt>git filter-branch --tree-filter 'rm filename' HEAD</tt></pre>
571 </div></div>
572 <div class="para"><p>However, if the file is absent from the tree of some commit,
573 a simple <tt>rm filename</tt> will fail for that tree and commit.
574 Thus you may instead want to use <tt>rm -f filename</tt> as the script.</p></div>
575 <div class="para"><p>Using <tt>--index-filter</tt> with <em>git-rm</em> yields a significantly faster
576 version. Like with using <tt>rm filename</tt>, <tt>git rm --cached filename</tt>
577 will fail if the file is absent from the tree of a commit. If you
578 want to "completely forget" a file, it does not matter when it entered
579 history, so we also add <tt>--ignore-unmatch</tt>:</p></div>
580 <div class="listingblock">
581 <div class="content">
582 <pre><tt>git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD</tt></pre>
583 </div></div>
584 <div class="para"><p>Now, you will get the rewritten history saved in HEAD.</p></div>
585 <div class="para"><p>To rewrite the repository to look as if <tt>foodir/</tt> had been its project
586 root, and discard all other history:</p></div>
587 <div class="listingblock">
588 <div class="content">
589 <pre><tt>git filter-branch --subdirectory-filter foodir -- --all</tt></pre>
590 </div></div>
591 <div class="para"><p>Thus you can, e.g., turn a library subdirectory into a repository of
592 its own. Note the <tt>--</tt> that separates <em>filter-branch</em> options from
593 revision options, and the <tt>--all</tt> to rewrite all branches and tags.</p></div>
594 <div class="para"><p>To set a commit (which typically is at the tip of another
595 history) to be the parent of the current initial commit, in
596 order to paste the other history behind the current history:</p></div>
597 <div class="listingblock">
598 <div class="content">
599 <pre><tt>git filter-branch --parent-filter 'sed "s/^\$/-p &lt;graft-id&gt;/"' HEAD</tt></pre>
600 </div></div>
601 <div class="para"><p>(if the parent string is empty - which happens when we are dealing with
602 the initial commit - add graftcommit as a parent). Note that this assumes
603 history with a single root (that is, no merge without common ancestors
604 happened). If this is not the case, use:</p></div>
605 <div class="listingblock">
606 <div class="content">
607 <pre><tt>git filter-branch --parent-filter \
608 'test $GIT_COMMIT = &lt;commit-id&gt; &amp;&amp; echo "-p &lt;graft-id&gt;" || cat' HEAD</tt></pre>
609 </div></div>
610 <div class="para"><p>or even simpler:</p></div>
611 <div class="listingblock">
612 <div class="content">
613 <pre><tt>echo "$commit-id $graft-id" &gt;&gt; .git/info/grafts
614 git filter-branch $graft-id..HEAD</tt></pre>
615 </div></div>
616 <div class="para"><p>To remove commits authored by "Darl McBribe" from the history:</p></div>
617 <div class="listingblock">
618 <div class="content">
619 <pre><tt>git filter-branch --commit-filter '
620 if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ];
621 then
622 skip_commit "$@";
623 else
624 git commit-tree "$@";
625 fi' HEAD</tt></pre>
626 </div></div>
627 <div class="para"><p>The function <em>skip_commit</em> is defined as follows:</p></div>
628 <div class="listingblock">
629 <div class="content">
630 <pre><tt>skip_commit()
632 shift;
633 while [ -n "$1" ];
635 shift;
636 map "$1";
637 shift;
638 done;
639 }</tt></pre>
640 </div></div>
641 <div class="para"><p>The shift magic first throws away the tree id and then the -p
642 parameters. Note that this handles merges properly! In case Darl
643 committed a merge between P1 and P2, it will be propagated properly
644 and all children of the merge will become merge commits with P1,P2
645 as their parents instead of the merge commit.</p></div>
646 <div class="para"><p>You can rewrite the commit log messages using <tt>--msg-filter</tt>. For
647 example, <em>git-svn-id</em> strings in a repository created by <em>git-svn</em> can
648 be removed this way:</p></div>
649 <div class="listingblock">
650 <div class="content">
651 <pre><tt>git filter-branch --msg-filter '
652 sed -e "/^git-svn-id:/d"
653 '</tt></pre>
654 </div></div>
655 <div class="para"><p>To restrict rewriting to only part of the history, specify a revision
656 range in addition to the new branch name. The new branch name will
657 point to the top-most revision that a <em>git-rev-list</em> of this range
658 will print.</p></div>
659 <div class="para"><p>If you need to add <em>Acked-by</em> lines to, say, the last 10 commits (none
660 of which is a merge), use this command:</p></div>
661 <div class="listingblock">
662 <div class="content">
663 <pre><tt>git filter-branch --msg-filter '
664 cat &amp;&amp;
665 echo "Acked-by: Bugs Bunny &lt;bunny@bugzilla.org&gt;"
666 ' HEAD~10..HEAD</tt></pre>
667 </div></div>
668 <div class="para"><p><strong>NOTE</strong> the changes introduced by the commits, and which are not reverted
669 by subsequent commits, will still be in the rewritten branch. If you want
670 to throw out _changes_ together with the commits, you should use the
671 interactive mode of <em>git-rebase</em>.</p></div>
672 <div class="para"><p>Consider this history:</p></div>
673 <div class="listingblock">
674 <div class="content">
675 <pre><tt> D--E--F--G--H
677 A--B-----C</tt></pre>
678 </div></div>
679 <div class="para"><p>To rewrite only commits D,E,F,G,H, but leave A, B and C alone, use:</p></div>
680 <div class="listingblock">
681 <div class="content">
682 <pre><tt>git filter-branch ... C..H</tt></pre>
683 </div></div>
684 <div class="para"><p>To rewrite commits E,F,G,H, use one of these:</p></div>
685 <div class="listingblock">
686 <div class="content">
687 <pre><tt>git filter-branch ... C..H --not D
688 git filter-branch ... D..H --not C</tt></pre>
689 </div></div>
690 <div class="para"><p>To move the whole tree into a subdirectory, or remove it from there:</p></div>
691 <div class="listingblock">
692 <div class="content">
693 <pre><tt>git filter-branch --index-filter \
694 'git ls-files -s | sed "s-\t-&amp;newsubdir/-" |
695 GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
696 git update-index --index-info &amp;&amp;
697 mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD</tt></pre>
698 </div></div>
699 </div>
700 <h2 id="_checklist_for_shrinking_a_repository">Checklist for Shrinking a Repository</h2>
701 <div class="sectionbody">
702 <div class="para"><p>git-filter-branch is often used to get rid of a subset of files,
703 usually with some combination of <tt>--index-filter</tt> and
704 <tt>--subdirectory-filter</tt>. People expect the resulting repository to
705 be smaller than the original, but you need a few more steps to
706 actually make it smaller, because git tries hard not to lose your
707 objects until you tell it to. First make sure that:</p></div>
708 <div class="ilist"><ul>
709 <li>
711 You really removed all variants of a filename, if a blob was moved
712 over its lifetime. <tt>git log --name-only --follow --all --
713 filename</tt> can help you find renames.
714 </p>
715 </li>
716 <li>
718 You really filtered all refs: use <tt>--tag-name-filter cat --
719 --all</tt> when calling git-filter-branch.
720 </p>
721 </li>
722 </ul></div>
723 <div class="para"><p>Then there are two ways to get a smaller repository. A safer way is
724 to clone, that keeps your original intact.</p></div>
725 <div class="ilist"><ul>
726 <li>
728 Clone it with <tt>git clone file:///path/to/repo</tt>. The clone
729 will not have the removed objects. See <a href="git-clone.html">git-clone(1)</a>. (Note
730 that cloning with a plain path just hardlinks everything!)
731 </p>
732 </li>
733 </ul></div>
734 <div class="para"><p>If you really don't want to clone it, for whatever reasons, check the
735 following points instead (in this order). This is a very destructive
736 approach, so <strong>make a backup</strong> or go back to cloning it. You have been
737 warned.</p></div>
738 <div class="ilist"><ul>
739 <li>
741 Remove the original refs backed up by git-filter-branch: say <tt>git
742 for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git
743 update-ref -d</tt>.
744 </p>
745 </li>
746 <li>
748 Expire all reflogs with <tt>git reflog expire --expire=now --all</tt>.
749 </p>
750 </li>
751 <li>
753 Garbage collect all unreferenced objects with <tt>git gc --prune=now</tt>
754 (or if your git-gc is not new enough to support arguments to
755 <tt>--prune</tt>, use <tt>git repack -ad; git prune</tt> instead).
756 </p>
757 </li>
758 </ul></div>
759 </div>
760 <h2 id="_author">Author</h2>
761 <div class="sectionbody">
762 <div class="para"><p>Written by Petr "Pasky" Baudis &lt;pasky@suse.cz&gt;,
763 and the git list &lt;git@vger.kernel.org&gt;</p></div>
764 </div>
765 <h2 id="_documentation">Documentation</h2>
766 <div class="sectionbody">
767 <div class="para"><p>Documentation by Petr Baudis and the git list.</p></div>
768 </div>
769 <h2 id="_git">GIT</h2>
770 <div class="sectionbody">
771 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
772 </div>
773 <div id="footer">
774 <div id="footer-text">
775 Last updated 2009-10-04 09:54:40 UTC
776 </div>
777 </div>
778 </body>
779 </html>