# How to git diff files in renamed directories

4 messages from 2012-03-15 to 2012-03-15. Participants: Patrick Sabin, Damien Wyart, Neal Kreitzinger, Junio C Hamano.
Thread: https://gitlist.dev/t/29956

## Patrick Sabin, 2012-03-15 08:32

Subject: How to git diff files in renamed directories
Message-ID: <CAGATVH7KCr+dJNpx18==3BT8pzsvKeV5aYRWKts7xH0YZ8yaKw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGATVH7KCr%2BdJNpx18%3D%3D3BT8pzsvKeV5aYRWKts7xH0YZ8yaKw%40mail.gmail.com

```
Hi,

I want to diff a renamed file (to a different directory) in different commits.

File a was moved to the file subdir/c

I tried:

$ git diff b616d 0aa0 -- subdir/c a

but git seems to always diff against /dev/null:

diff --git a/a b/a
new file mode 100644
index 0000000..2e5ada8
--- /dev/null
+++ b/a
@@ -0,0 +1 @@
+File a
diff --git a/subdir/c b/subdir/c
deleted file mode 100644
index 24c846c..0000000
--- a/subdir/c
+++ /dev/null
@@ -1,2 +0,0 @@
-File b
-Another b change.

git log --follow subdir/c   recognizes that the file has been renamed
and moved to subdirectory.

Is there any way to get such a diff in git?

Regards,
Patrick

```

## Damien Wyart, 2012-03-15 08:51

Subject: Re: How to git diff files in renamed directories
Message-ID: <20120315085105.GA27243@brouette>
URL: https://gitlist.dev/e/20120315085105.GA27243%40brouette
In-Reply-To: <CAGATVH7KCr+dJNpx18==3BT8pzsvKeV5aYRWKts7xH0YZ8yaKw@mail.gmail.com>

```
Hi,

* Patrick Sabin <patrick.just4fun@gmail.com> [2012-03-15 09:32]:
> I want to diff a renamed file (to a different directory) in different
> commits.

You can try the "-C" option to git diff. In some cases, "-C -C" might be
needed (with potentially bad performance).

-- 
Damien

```

## Neal Kreitzinger, 2012-03-15 10:30

Subject: Re: How to git diff files in renamed directories
Message-ID: <4F61C4BB.20908@gmail.com>
URL: https://gitlist.dev/e/4F61C4BB.20908%40gmail.com
In-Reply-To: <CAGATVH7KCr+dJNpx18==3BT8pzsvKeV5aYRWKts7xH0YZ8yaKw@mail.gmail.com>

```
On 3/15/2012 3:32 AM, Patrick Sabin wrote:
>
> I want to diff a renamed file (to a different directory) in different commits.
>
> File a was moved to the file subdir/c
>
> I tried:
>
> $ git diff b616d 0aa0 -- subdir/c a
>
> but git seems to always diff against /dev/null:
>
> diff --git a/a b/a
> new file mode 100644
> index 0000000..2e5ada8
> --- /dev/null
> +++ b/a
> @@ -0,0 +1 @@
> +File a
> diff --git a/subdir/c b/subdir/c
> deleted file mode 100644
> index 24c846c..0000000
> --- a/subdir/c
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -File b
> -Another b change.
>
> git log --follow subdir/c   recognizes that the file has been renamed
> and moved to subdirectory.
>
> Is there any way to get such a diff in git?
>
git diff b616d:a 0aa0:subdir/c is one way to do it.

v/r,
neal

```

## Junio C Hamano, 2012-03-15 20:49

Subject: Re: How to git diff files in renamed directories
Message-ID: <7vbonxk2sg.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbonxk2sg.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAGATVH7KCr+dJNpx18==3BT8pzsvKeV5aYRWKts7xH0YZ8yaKw@mail.gmail.com>

```
Patrick Sabin <patrick.just4fun@gmail.com> writes:

> I want to diff a renamed file (to a different directory) in different commits.
>
> File a was moved to the file subdir/c
>
> I tried:
>
> $ git diff b616d 0aa0 -- subdir/c a

Does

    $ git diff -M b616d 0aa0 -- subdir/c a

match them up?    

```
