@@ -282,18 +282,18 @@ <h2>SYNOPSIS</h2>
282282</ div >
283283< h2 > DESCRIPTION</ h2 >
284284< div class ="sectionbody ">
285- < p > Lets you rewrite git revision history by creating a new branch from
286- your current branch , applying custom filters on each revision.
285+ < p > Lets you rewrite git revision history by rewriting the branches mentioned
286+ in the <rev-list options> , applying custom filters on each revision.
287287Those filters can modify each tree (e.g. removing a file or running
288288a perl rewrite on all files) or information about each commit.
289289Otherwise, all information (including original commit times or merge
290290information) will be preserved.</ p >
291- < p > The command takes the new branch name as a mandatory argument and
292- the filters as optional arguments. If you specify no filters, the
293- commits will be recommitted without any changes, which would normally
294- have no effect. Nevertheless, this may be useful in the future for
295- compensating for some git bugs or such, therefore such a usage is
296- permitted.</ p >
291+ < p > The command will only rewrite the _positive_ refs mentioned in the
292+ command line (i.e. if you pass < em > a..b </ em > , only < em > b </ em > will be rewritten).
293+ If you specify no filters, the commits will be recommitted without any
294+ changes, which would normally have no effect. Nevertheless, this may be
295+ useful in the future for compensating for some git bugs or such,
296+ therefore such a usage is permitted.</ p >
297297< p > < strong > WARNING</ strong > ! The rewritten history will have different object names for all
298298the objects and will not converge with the original branch. You will not
299299be able to easily push and distribute the rewritten branch on top of the
@@ -304,8 +304,8 @@ <h2>DESCRIPTION</h2>
304304if different from the rewritten ones, will be stored in the namespace
305305< em > refs/original/</ em > .</ p >
306306< p > Note that since this operation is extensively I/O expensive, it might
307- be a good idea to redirect the temporary directory off-disk, e.g. on
308- tmpfs. Reportedly the speedup is very noticeable.</ p >
307+ be a good idea to redirect the temporary directory off-disk with the
308+ < em > -d </ em > option, e.g. on tmpfs. Reportedly the speedup is very noticeable.</ p >
309309< h3 > Filters</ h3 >
310310< p > The filters are applied in the order as listed below. The <command>
311311argument is always evaluated in shell using the < em > eval</ em > command (with the
@@ -396,6 +396,10 @@ <h2>OPTIONS</h2>
396396< p > As a special extension, the commit filter may emit multiple
397397commit ids; in that case, ancestors of the original commit will
398398have all of them as parents.</ p >
399+ < p > You can use the < em > map</ em > convenience function in this filter, and other
400+ convenience functions, too. For example, calling < em > skip_commit "$@"</ em >
401+ will leave out the current commit (but not its changes! If you want
402+ that, use < a href ="git-rebase.html "> git-rebase(1)</ a > instead).</ p >
399403</ dd >
400404< dt >
401405--tag-name-filter <command>
@@ -494,8 +498,8 @@ <h2>Examples</h2>
494498< div class ="content ">
495499< pre > < tt > git filter-branch --parent-filter 'sed "s/^\$/-p <graft-id>/"' HEAD</ tt > </ pre >
496500</ div > </ div >
497- < p > (if the parent string is empty - therefore we are dealing with the
498- initial commit - add graftcommit as a parent). Note that this assumes
501+ < p > (if the parent string is empty - which happens when we are dealing with
502+ the initial commit - add graftcommit as a parent). Note that this assumes
499503history with a single root (that is, no merge without common ancestors
500504happened). If this is not the case, use:</ p >
501505< div class ="listingblock ">
@@ -515,17 +519,29 @@ <h2>Examples</h2>
515519< pre > < tt > git filter-branch --commit-filter '
516520 if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ];
517521 then
518- shift;
519- while [ -n "$1" ];
520- do
521- shift;
522- echo "$1";
523- shift;
524- done;
522+ skip_commit "$@";
525523 else
526524 git commit-tree "$@";
527525 fi' HEAD</ tt > </ pre >
528526</ div > </ div >
527+ < p > Note that the changes introduced by the commits, and not reverted by
528+ subsequent commits, will still be in the rewritten branch. If you want
529+ to throw out _changes_ together with the commits, you should use the
530+ interactive mode of < a href ="git-rebase.html "> git-rebase(1)</ a > .</ p >
531+ < p > The function < em > skip_commits</ em > is defined as follows:</ p >
532+ < div class ="listingblock ">
533+ < div class ="content ">
534+ < pre > < tt > skip_commit()
535+ {
536+ shift;
537+ while [ -n "$1" ];
538+ do
539+ shift;
540+ map "$1";
541+ shift;
542+ done;
543+ }</ tt > </ pre >
544+ </ div > </ div >
529545< p > The shift magic first throws away the tree id and then the -p
530546parameters. Note that this handles merges properly! In case Darl
531547committed a merge between P1 and P2, it will be propagated properly
@@ -535,8 +551,8 @@ <h2>Examples</h2>
535551range in addition to the new branch name. The new branch name will
536552point to the top-most revision that a < em > git rev-list</ em > of this range
537553will print.</ p >
538- < p > Note that the changes introduced by the commits, and not reverted by
539- subsequent commits, will still be in the rewritten branch. If you want
554+ < p > < strong > NOTE </ strong > the changes introduced by the commits, and which are not reverted
555+ by subsequent commits, will still be in the rewritten branch. If you want
540556to throw out _changes_ together with the commits, you should use the
541557interactive mode of < a href ="git-rebase.html "> git-rebase(1)</ a > .</ p >
542558< p > Consider this history:</ p >
@@ -582,7 +598,7 @@ <h2>GIT</h2>
582598</ div >
583599< div id ="footer ">
584600< div id ="footer-text ">
585- Last updated 31-Aug -2007 07:55:56 UTC
601+ Last updated 01-Sep -2007 11:16:25 UTC
586602</ div >
587603</ div >
588604</ body >
0 commit comments