# git filter-branch examples on man page are outdated

4 messages from 2009-02-12 to 2009-02-12. Participants: Jeffrey Chupp, Jacob Helwig, Junio C Hamano, Johannes Schindelin.
Thread: https://gitlist.dev/t/17754

## Jeffrey Chupp, 2009-02-12 16:33

Subject: git filter-branch examples on man page are outdated
Message-ID: <AB13D1C5-4464-49B5-8314-FCB1E249BF22@semanticart.com>
URL: https://gitlist.dev/e/AB13D1C5-4464-49B5-8314-FCB1E249BF22%40semanticart.com

```
http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html
mb:repo jeff$ ls db/data/us_cities.data.insert.sql
db/data/us_cities.data.insert.sql
mb:repo jeff$ git filter-branch --index-filter 'git rm -f --cached db/ 
data/us_cities.data.insert.sql' HEAD
Rewrite d54d3041d7d5739b3093f802fc1ef45f3c8e5e16 (1/2713)fatal:  
pathspec 'db/data/us_cities.data.insert.sql' did not match any files
index filter failed: git rm -f --cached db/data/ 
us_cities.data.insert.sql

ekidd speculated that since the file wasn't in the first version of  
the repo, it was borking.  He was right.  Next he told me to try

git filter-branch --index-filter 'git rm -f --cached db/data/ 
us_cities.data.insert.sql || true'

which worked.  He also asked me to point this out on this list:

ekidd:semanticart: Commit 8c1ce0f46b85d40f215084eed7313896300082df  
changed the behavior without updating the example in the man page. If  
you're feeling inspired, you may want to post this to git@vger.

Thanks and apologies for any etiquette breaches, I don't know what I'm  
doing :)

-jeff

```

## Jacob Helwig, 2009-02-12 18:01

Subject: [PATCH] Add 'rm -f' equivalent to 'git rm' example of filter-branch --index-filter
Message-ID: <1234461670-25657-1-git-send-email-jacob.helwig@gmail.com>
URL: https://gitlist.dev/e/1234461670-25657-1-git-send-email-jacob.helwig%40gmail.com
In-Reply-To: <AB13D1C5-4464-49B5-8314-FCB1E249BF22@semanticart.com>

```
Signed-off-by: Jacob Helwig <jacob.helwig@gmail.com>
---
 Documentation/git-filter-branch.txt |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 451950b..1fbbbb4 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -212,6 +212,11 @@ git filter-branch --index-filter 'git rm --cached filename' HEAD
 
 Now, you will get the rewritten history saved in HEAD.
 
+As with using `rm filename`, `git rm --cached filename` will fail
+if the file is absent from the tree of a commit.  If it is not important
+whether the file is already absent from the tree, you can use
+`git rm --cached --ignore-unmatch filename` instead.
+
 To rewrite the repository to look as if `foodir/` had been its project
 root, and discard all other history:
 
-- 
1.6.1.1

```

## Junio C Hamano, 2009-02-12 22:47

Subject: Re: [PATCH] Add 'rm -f' equivalent to 'git rm' example of filter-branch --index-filter
Message-ID: <7v4oyzjmqv.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4oyzjmqv.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1234461670-25657-1-git-send-email-jacob.helwig@gmail.com>

```
Jacob Helwig <jacob.helwig@gmail.com> writes:

> Signed-off-by: Jacob Helwig <jacob.helwig@gmail.com>
> ---
>  Documentation/git-filter-branch.txt |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
> index 451950b..1fbbbb4 100644
> --- a/Documentation/git-filter-branch.txt
> +++ b/Documentation/git-filter-branch.txt
> @@ -212,6 +212,11 @@ git filter-branch --index-filter 'git rm --cached filename' HEAD
>  
>  Now, you will get the rewritten history saved in HEAD.
>  
> +As with using `rm filename`, `git rm --cached filename` will fail
> +if the file is absent from the tree of a commit.  If it is not important
> +whether the file is already absent from the tree, you can use
> +`git rm --cached --ignore-unmatch filename` instead.
> +
>  To rewrite the repository to look as if `foodir/` had been its project
>  root, and discard all other history:


Looks sane to me.  Objections?

```

## Johannes Schindelin, 2009-02-12 23:06

Subject: Re: [PATCH] Add 'rm -f' equivalent to 'git rm' example of filter-branch --index-filter
Message-ID: <alpine.DEB.1.00.0902130005580.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902130005580.10279%40pacific.mpi-cbg.de
In-Reply-To: <7v4oyzjmqv.fsf@gitster.siamese.dyndns.org>

```
Hi,

On Thu, 12 Feb 2009, Junio C Hamano wrote:

> Jacob Helwig <jacob.helwig@gmail.com> writes:
> 
> > Signed-off-by: Jacob Helwig <jacob.helwig@gmail.com>
> > ---
> >  Documentation/git-filter-branch.txt |    5 +++++
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
> > index 451950b..1fbbbb4 100644
> > --- a/Documentation/git-filter-branch.txt
> > +++ b/Documentation/git-filter-branch.txt
> > @@ -212,6 +212,11 @@ git filter-branch --index-filter 'git rm --cached filename' HEAD
> >  
> >  Now, you will get the rewritten history saved in HEAD.
> >  
> > +As with using `rm filename`, `git rm --cached filename` will fail
> > +if the file is absent from the tree of a commit.  If it is not important
> > +whether the file is already absent from the tree, you can use
> > +`git rm --cached --ignore-unmatch filename` instead.
> > +
> >  To rewrite the repository to look as if `foodir/` had been its project
> >  root, and discard all other history:
> 
> 
> Looks sane to me.  Objections?

Definitely no objections from me.

Ciao,
Dscho

```
