X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=Documentation%2Fgit-filter-branch.txt;h=7747c4877de4b7cae352b982c6c1a8b06ca8556d;hb=c6d8f7635f619f6576dccf17c1f1264d2cc37a2a;hp=506c37af7021e2e16caab5ffe72bca9bc2f28927;hpb=b71ce7f3f13ebd0e212bdda82b012ee36df4f63f;p=git.git diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt index 506c37af7..7747c4877 100644 --- a/Documentation/git-filter-branch.txt +++ b/Documentation/git-filter-branch.txt @@ -8,12 +8,12 @@ git-filter-branch - Rewrite branches SYNOPSIS -------- [verse] -'git-filter-branch' [--env-filter ] [--tree-filter ] +'git filter-branch' [--env-filter ] [--tree-filter ] [--index-filter ] [--parent-filter ] [--msg-filter ] [--commit-filter ] [--tag-name-filter ] [--subdirectory-filter ] [--original ] [-d ] [-f | --force] - [...] + [--] [...] DESCRIPTION ----------- @@ -31,6 +31,9 @@ changes, which would normally have no effect. Nevertheless, this may be useful in the future for compensating for some git bugs or such, therefore such a usage is permitted. +*NOTE*: This command honors `.git/info/grafts`. If you have any grafts +defined, running this command will make them permanent. + *WARNING*! The rewritten history will have different object names for all the objects and will not converge with the original branch. You will not be able to easily push and distribute the rewritten branch on top of the @@ -95,7 +98,7 @@ OPTIONS 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 - a format accepted by linkgit:git-commit-tree[1]: empty for + 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. @@ -108,18 +111,18 @@ OPTIONS --commit-filter :: This is the filter for performing the commit. If this filter is specified, it will be called instead of the - linkgit:git-commit-tree[1] command, with arguments of the form + 'git-commit-tree' command, with arguments of the form " [-p ]..." 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, ancestors of the original commit will +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 linkgit:git-rebase[1] instead). +that, use 'git-rebase' instead). --tag-name-filter :: This is the filter for rewriting tag names. When passed, @@ -161,16 +164,17 @@ to other tags will be rewritten to point to the underlying commit. does this in the '.git-rewrite/' directory but you can override that choice by this parameter. --f|--force:: - `git filter-branch` refuses to start with an existing temporary +-f:: +--force:: + 'git-filter-branch' refuses to start with an existing temporary directory or when there are already refs starting with 'refs/original/', unless forced. -:: - When options are given after the new branch name, they will - be passed to linkgit:git-rev-list[1]. Only commits in the resulting - output will be filtered, although the filtered commits can still - reference parents which are outside of that set. +...:: + Arguments for 'git-rev-list'. All positive refs included by + these options are rewritten. You may also specify options + such as '--all', but you must use '--' to separate them from + the 'git-filter-branch' options. Examples @@ -190,11 +194,22 @@ Thus you may instead want to use `rm -f filename` as the script. A significantly faster version: -------------------------------------------------------------------------- -git filter-branch --index-filter 'git update-index --remove filename' HEAD +git filter-branch --index-filter 'git rm --cached filename' HEAD -------------------------------------------------------------------------- Now, you will get the rewritten history saved in HEAD. +To rewrite the repository to look as if `foodir/` had been its project +root, and discard all other history: + +------------------------------------------------------- +git filter-branch --subdirectory-filter foodir -- --all +------------------------------------------------------- + +Thus you can, e.g., turn a library subdirectory into a repository of +its own. Note the `\--` that separates 'filter-branch' options from +revision options, and the `\--all` to rewrite all branches and tags. + To set a commit (which typically is at the tip of another history) to be the parent of the current initial commit, in order to paste the other history behind the current history: @@ -254,7 +269,7 @@ and all children of the merge will become merge commits with P1,P2 as their parents instead of the merge commit. You can rewrite the commit log messages using `--msg-filter`. For -example, `git-svn-id` strings in a repository created by `git-svn` can +example, 'git-svn-id' strings in a repository created by 'git-svn' can be removed this way: ------------------------------------------------------- @@ -265,13 +280,13 @@ git filter-branch --msg-filter ' To restrict rewriting to only part of the history, specify a revision range in addition to the new branch name. The new branch name will -point to the top-most revision that a 'git rev-list' of this range +point to the top-most revision that a 'git-rev-list' of this range will print. *NOTE* the changes introduced by the commits, and which are not reverted by subsequent commits, will still be in the rewritten branch. If you want to throw out _changes_ together with the commits, you should use the -interactive mode of linkgit:git-rebase[1]. +interactive mode of 'git-rebase'. Consider this history: @@ -317,4 +332,4 @@ Documentation by Petr Baudis and the git list. GIT --- -Part of the linkgit:git[7] suite +Part of the linkgit:git[1] suite