Saving the entire git diff between two commits in a text file

is there a way where I could save the entire difference between two diff in a text file?

Suppose I wanted all the changes between A1 and A10 on master branch.

--A11-A10-A9-A8-A7-A6-A5-A4-A3-A2-A1-master

Or, is there a way where I could get the entire diff in Terminal which I could copy+paste?


Solution 1:

Sure:

git diff A10..A1 > my.diff

Solution 2:

git diff {commit1} {commit2} > diff.txt

Being {commit1} and {commit2} a reference to the initial and finish commits you want to compare (reference could be an entire or partial SHA, a tag, HEAD.....)

Solution 3:

From man page..


git format-patch -k --stdout R1..R2