Question

Is it possible to add a list of files somewhere to a changelist or file or something, and to run git diff commit1 commit2 myListOfFiles and to get the diff of just that list of files? Or is it possible to create a macro that expands to that list? and to be able to remove and add from that list or change it?

This would be super-useful for creating patches for just certain files, not having to type down the paths for all 20 files I want to diff.

Was it helpful?

Solution

Simply do:

git diff commit1 commit2 -- $(cat /path/to/listfile)

You can alias this command by the following line to your .gitconfig:

[alias]
    listdiff = "!f() { git diff $1 $2 -- $(cat \"$3\"); }; f"

and call it with

git listdiff commit1 commit2 path/to/file
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top