BazZy BazZy - 1 year ago 100
Git Question

Git diff --name-only and copy that list

I just want to get a list of changed files between two revisions, which is simple:

git diff -–name-only commit1 commit2 > /path/to/my/file

But, what should I write, if I want copy all that listed files to another place? And I need completely identical directory structure for copied files.

For example, I have modified and added files:


I want to have in
all those changed and added files:


Answer Source

Try the following command, which I have tested:

$ cp -pv --parents `git diff --name-only` DESTINATION-DIRECTORY
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download