How to split git diff output into individual files

Viewed 759

I want to split git diff output into individual files.

Say there are three changed files. git diff will output all three diffs once, but is there any way to separate them into three individual diff files instead?

1 Answers

A bare bone example bash script.

#!/bin/bash
git diff --name-only | while read p
do
    git diff -- "$p"
    # do something...
done
Related