Skip to content

Commit 3bc427e

Browse files
trastgitster
authored andcommitted
Documentation: filter-branch: show --ignore-unmatch in main index-filter example
Rearrange the example usage of git filter-branch --index-filter 'git rm --cached ...' so that --ignore-unmatch is in the main example block. People keep stumbling over the (lack of this) option to the point where it is a FAQ, so we would want to expose the most common usage where it stands out. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2464456 commit 3bc427e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Documentation/git-filter-branch.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ OPTIONS
9191
--index-filter <command>::
9292
This is the filter for rewriting the index. It is similar to the
9393
tree filter but does not check out the tree, which makes it much
94-
faster. For hairy cases, see linkgit:git-update-index[1].
94+
faster. Frequently used with `git rm \--cached
95+
\--ignore-unmatch ...`, see EXAMPLES below. For hairy
96+
cases, see linkgit:git-update-index[1].
9597

9698
--parent-filter <command>::
9799
This is the filter for rewriting the commit's parent list.
@@ -204,19 +206,18 @@ However, if the file is absent from the tree of some commit,
204206
a simple `rm filename` will fail for that tree and commit.
205207
Thus you may instead want to use `rm -f filename` as the script.
206208

207-
A significantly faster version:
209+
Using `\--index-filter` with 'git-rm' yields a significantly faster
210+
version. Like with using `rm filename`, `git rm --cached filename`
211+
will fail if the file is absent from the tree of a commit. If you
212+
want to "completely forget" a file, it does not matter when it entered
213+
history, so we also add `\--ignore-unmatch`:
208214

209215
--------------------------------------------------------------------------
210-
git filter-branch --index-filter 'git rm --cached filename' HEAD
216+
git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD
211217
--------------------------------------------------------------------------
212218

213219
Now, you will get the rewritten history saved in HEAD.
214220

215-
As with using `rm filename`, `git rm --cached filename` will fail
216-
if the file is absent from the tree of a commit. If it is not important
217-
whether the file is already absent from the tree, you can use
218-
`git rm --cached --ignore-unmatch filename` instead.
219-
220221
To rewrite the repository to look as if `foodir/` had been its project
221222
root, and discard all other history:
222223

0 commit comments

Comments
 (0)