# git log --patch for a particular file

2 messages from 2023-10-16 to 2023-10-16. Participants: Victor Porton, Kristoffer Haugsbakk.
Thread: https://gitlist.dev/t/60372

## Victor Porton, 2023-10-16 10:20

Subject: git log --patch for a particular file
Message-ID: <75545e1c-ce62-4b49-983e-1e7b1afb2fab@gmail.com>
URL: https://gitlist.dev/e/75545e1c-ce62-4b49-983e-1e7b1afb2fab%40gmail.com

```
I want this:

git log --patch -- server/src/api/docs.py

to print changes only for the file server/src/api/docs.py.

Currently, it in some reasons outputs nothing (this seems not to be an 
intended behavior and could be counted as a bug).

More generally,
git log --patch -- A B C
could log changes in files A, B, C (only).

It is questionable, whether to output commit information (commit hash, 
user email, etc.) for commits that don't change specified file(s). I 
would vote to indeed output this information, not to confuse the user 
about the order of commits.

```

## Kristoffer Haugsbakk, 2023-10-16 10:29

Subject: Re: git log --patch for a particular file
Message-ID: <d34d9b64-4760-43e8-975c-a3ef53048530@app.fastmail.com>
URL: https://gitlist.dev/e/d34d9b64-4760-43e8-975c-a3ef53048530%40app.fastmail.com
In-Reply-To: <75545e1c-ce62-4b49-983e-1e7b1afb2fab@gmail.com>

```
Hi

On Mon, Oct 16, 2023, at 12:20, Victor Porton wrote:
> I want this:
>
> git log --patch -- server/src/api/docs.py
>
> to print changes only for the file server/src/api/docs.py.

That's how it works for me.

> Currently, it in some reasons outputs nothing (this seems not to be an
> intended behavior and could be counted as a bug).

Does it output nothing on *merge* commits? That's intended.

Try using `-m` as well.

https://stackoverflow.com/a/37801468/1725151

> It is questionable, whether to output commit information (commit hash,
> user email, etc.) for commits that don't change specified file(s). I
> would vote to indeed output this information, not to confuse the user
> about the order of commits.

You can customize the output with `--format=`.

> More generally,
> git log --patch -- A B C
> could log changes in files A, B, C (only).

If I name two files I only get commits that touch any of those files. And
diffs only for them.

-- 
Kristoffer Haugsbakk

```
