Home Explore Blog CI



git

2nd chunk of `Documentation/git-filter-branch.adoc`
b3efa7a37f0272b836de0e2d6b81a828d844e0b71afa4daf0000000100000fa3
 temporary directory off-disk with the
`-d` option, e.g. on tmpfs.  Reportedly the speedup is very noticeable.


Filters
~~~~~~~

The filters are applied in the order as listed below.  The <command>
argument is always evaluated in the shell context using the 'eval' command
(with the notable exception of the commit filter, for technical reasons).
Prior to that, the `$GIT_COMMIT` environment variable will be set to contain
the id of the commit being rewritten.  Also, GIT_AUTHOR_NAME,
GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
and GIT_COMMITTER_DATE are taken from the current commit and exported to
the environment, in order to affect the author and committer identities of
the replacement commit created by linkgit:git-commit-tree[1] after the
filters have run.

If any evaluation of <command> returns a non-zero exit status, the whole
operation will be aborted.

A 'map' function is available that takes an "original sha1 id" argument
and outputs a "rewritten sha1 id" if the commit has been already
rewritten, and "original sha1 id" otherwise; the 'map' function can
return several ids on separate lines if your commit filter emitted
multiple commits.


OPTIONS
-------

--setup <command>::
	This is not a real filter executed for each commit but a one
	time setup just before the loop. Therefore no commit-specific
	variables are defined yet.  Functions or variables defined here
	can be used or modified in the following filter steps except
	the commit filter, for technical reasons.

--subdirectory-filter <directory>::
	Only look at the history which touches the given subdirectory.
	The result will contain that directory (and only that) as its
	project root. Implies <<Remap_to_ancestor>>.

--env-filter <command>::
	This filter may be used if you only need to modify the environment
	in which the commit will be performed.  Specifically, you might
	want to rewrite the author/committer name/email/time environment
	variables (see linkgit:git-commit-tree[1] for details).

--tree-filter <command>::
	This is the filter for rewriting the tree and its contents.
	The argument is evaluated in shell with the working
	directory set to the root of the checked out tree.  The new tree
	is then used as-is (new files are auto-added, disappeared files
	are auto-removed - neither .gitignore files nor any other ignore
	rules *HAVE ANY EFFECT*!).

--index-filter <command>::
	This is the filter for rewriting the index.  It is similar to the
	tree filter but does not check out the tree, which makes it much
	faster.  Frequently used with `git rm --cached
	--ignore-unmatch ...`, see EXAMPLES below.  For hairy
	cases, see linkgit:git-update-index[1].

--parent-filter <command>::
	This is the filter for rewriting the commit's parent list.
	It will receive the parent string on stdin and shall output
	the new parent string on stdout.  The parent string is in
	the format described in linkgit:git-commit-tree[1]: empty for
	the initial commit, "-p parent" for a normal commit and
	"-p parent1 -p parent2 -p parent3 ..." for a merge commit.

--msg-filter <command>::
	This is the filter for rewriting the commit messages.
	The argument is evaluated in the shell with the original
	commit message on standard input; its standard output is
	used as the new commit message.

--commit-filter <command>::
	This is the filter for performing the commit.
	If this filter is specified, it will be called instead of the
	'git commit-tree' command, with arguments of the form
	"<TREE_ID> [(-p <PARENT_COMMIT_ID>)...]" and the log message on
	stdin.  The commit id is expected on stdout.
+
As a special extension, the commit filter may emit multiple
commit ids; in that case, the rewritten children of the original commit will
have all of them as parents.
+
You can use the 'map' convenience function in this filter, and other
convenience functions, too.  For example, calling 'skip_commit "$@"'
will leave out the current commit (but not its changes! If you want
that, use 'git

Title: Git Filter Branch Filters and Options
Summary
The git-filter-branch command uses various filters to rewrite Git revision history, including setup, subdirectory, environment, tree, index, parent, message, and commit filters, each with its own specific function and usage.