문제

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.

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top