This command will diff their whole history:
git diff branch1..branch2 –name-only
If you want to compare from their last common ancestor, then:
git diff branch1…branch2 –name-only
And now you can grep files that you want. From there it’s easy to write a little shell script that diffs two branches, file by file.
filenames=$(git diff branch1...branch2 --name-only | grep /db/migratons) IFS=' ' read -r -a filearr <<< "$filenames" for filename in "${filearr[@]}" do echo $(git diff branch1...branch2 -- "$filename") done
Create the git-command-name file and put it into the user/bin folder (you should parametrize input – branches as variables).
Git will recognise it as a command that you can call with:
git command-name branch1 branch2