Try the following command, which I have tested:

$ cp -pv --parents $(git diff --name-only) DESTINATION-DIRECTORY
Answer from York on Stack Overflow
🌐
Moakh
moakh.com › blog › git diff: only show filenames
Git Diff: Only Show Filenames | moakh
April 9, 2023 - You can use vim -p to open multiple files in Vim tabs, and the list of files can be passed in by using the --name-only flag with git diff like this:
Discussions

git - How to list only the names of files that changed between two commits - Stack Overflow
Just for someone who needs to focus only on Java files, this is my solution: ... Save this answer. ... Show activity on this post. In case someone is looking for the list of changed files, including staged files · git diff HEAD --name-only --relative --diff-filter=AMCR git diff HEAD --name-only ... More on stackoverflow.com
🌐 stackoverflow.com
Can I make 'git diff' only display the line numbers AND changed file names? - Stack Overflow
This should NOT be the accepted answer as it only solves half the problem- you still need to output which lines (for each file) that were changed. 2014-01-24T19:12:44.537Z+00:00 ... Why not use "git status"? It also tells you the untracked files. 2016-11-14T13:45:03.73Z+00:00 ... @JimmyPaul because sometimes you already have commited. For example you need to list changed file between master and your current advanced branch git diff --name... More on stackoverflow.com
🌐 stackoverflow.com
bash - Return list using git diff and grep - Unix & Linux Stack Exchange
Stack Exchange network consists ... trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange · The 2026 Annual Developer Survey is live— take the Survey today!. ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I'm using git diff to return the file names of files recently ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
name-only diff between branches shows changes, but regular diff for any specific file is empty
Do git diff --raw Does it show different hash or mode? More on reddit.com
🌐 r/git
4
1
August 9, 2024
🌐
Better Stack
betterstack.com › community › questions › list-names-of-changed-files-between-commits
How to List Only the Names of Files That Changed between Two Commits | Better Stack Community
June 24, 2024 - To list only the names of files that changed between two commits in Git, you can use the git diff command with the --name-only option.
🌐
Git
git-scm.com › docs › git-diff
Git - git-diff Documentation
Just like --name-only the file names are often encoded in UTF-8. ... Specify how differences in submodules are shown. When specifying --submodule=short the short format is used. This format just shows the names of the commits at the beginning and end of the range. When --submodule or --submodule=log is specified, the log format is used. This format lists the commits in the range like git-submodule[1] summary does.
🌐
Linux Hint
linuxhint.com › list-only-the-names-files-that-changed-between-two-commits
How to List Only the Names of Files that Changed Between Two Commits – Linux Hint
To list only the names of files that changed between two commits, the “$ git diff --name-only ” command can be utilized.
🌐
Quora
quora.com › How-do-you-list-only-the-file-name-changes-between-two-commits-in-git
How to list only the file name changes between two commits in git - Quora
Answer (1 of 8): > How do you list only the file name changes between two commits in git? With git diff, the solution is straightforward: [code]git diff --name-only commitA commitB [/code]If I may read between the lines and guess that you actually want the commit identifiers listed, along with ...
Find elsewhere
🌐
Explain Shell
explainshell.com › explain
explainshell.com - git diff --cached --name-only; git diff --name-only
git diff(1) distro · arch latest · ubuntu 26.04 --cached --name-only; git diff(1) distro · arch latest · ubuntu 26.04 --name-only ·
🌐
Makandra
makandracards.com › makandra › 15763-git-show-filenames-diff
Git: How to show only filenames for a diff - makandra dev
April 24, 2013 - Need a quick view of changed files without the full patch; `git diff --name-only` lists filenames, while `--stat` and `--numstat` add compact change counts.
🌐
GitHub
gist.github.com › digbot › 4d63c1a615be8c7de03acae63a410ea8
Git diff --name-only and copy that list · GitHub
May 27, 2019 - Git diff --name-only and copy that list · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
Codemia
codemia.io › home › knowledge hub › how to list only the names of files that changed between two commits
How to list only the names of files that changed between two commits | Codemia
September 23, 2025 - Let's explore some real-world scenarios where listing changed files can be particularly useful: When reviewing code, it can be beneficial to isolate changes file-by-file. Using git diff --name-only, you can quickly generate a list of files that require a deeper dive, ensuring you focus only ...
🌐
Reddit
reddit.com › r/git › name-only diff between branches shows changes, but regular diff for any specific file is empty
r/git on Reddit: name-only diff between branches shows changes, but regular diff for any specific file is empty
August 9, 2024 -

Edit [Solved]: As per u/ppww's comment, I wasn't in the root directory of the repo, so my paths were invalid.

If I do the following command, I get a really long list of changed files. Most of which I expect, but some shouldn't have changed:

git diff --name-only myBranch1 myBranch2

For example, one of the files mentioned in the diff is src/general/Log.php

But if I use the following command to check the difference in that particular file, it just prints an empty line and exits the diff:

git diff myBranch1 myBranch2 -- src/general/Log.php

Trying to diff a directory instead of a file does the same thing.

I did however confirm that if I do a full diff across the two branches (not name-only) it does actually show the differences, but as there is a lot in there, most of which isn't what I'm looking for, it would be really tedious to view the whole diff.

What am I doing wrong?

🌐
Git Examples
gitexamples.com › examples › d4796b08-6044-43ff-a457-446124b4e252
git diff <commitA> --name-only
You can combine this with other ... like git diff <commit> --name-only -- src/ to list only changed files under the src/ directory; swapping --name-only for --name-status (git diff <commit> --name-status) shows filenames plus a short status code like A, M, or D, and using a range such as git diff <old-commit> <new-commit> --name-only lists files changed between two specific commits instead of between <commit> and your current state...
🌐
Git Scripts
gitscripts.com › git-diff-name-only
Understanding git diff --name-only for Quick Insights
September 11, 2025 - The `git diff --name-only` command lists only the names of files that have differences between the working directory and the staging area or between two commits, making it a useful tool for quickly identifying changed files.
🌐
Sushihangover
sushihangover.github.io › git-getting-a-list-of-files-changed-between-branches
Git - Getting a list of files changed between branches - SushiHangover
June 4, 2015 - Getting a list of changed files between to different branches or tags could not be any easier when using the ‘–name-only’ diff option: git diff --name-only mono-3.2.5 mono-3.2.6 configure.in mcs/class/Facades/Makefile mcs/class/Facades/System.Dynamic.Runtime/TypeForwarders.cs mcs/class/Facades/System.Runtime.InteropServices.WindowsRuntime/AssemblyInfo.cs mcs/class/Facades/System.Runtime.InteropServices.WindowsRuntime/Makefile ...
🌐
Bassochette
bassochette.github.io › memo › 2016 › 12 › 21 › git-diff-show-only-file-names
git diff show only file names - coffee and 🚬
$ git diff --name-only · Stack overflow · ← Previous Archive Next → · 21 December 2016 · memo · git 5 ·
🌐
Git
git-scm.com › docs › git-diff-files › 2.17.0
Git - git-diff-files Documentation
Show only names and status of changed files. See the description of the --diff-filter option on what the status letters mean. ... Specify how differences in submodules are shown. When specifying --submodule=short the short format is used. This format just shows the names of the commits at the ...