Saving the entire git diff between two commits in a text file
GitDiffGit Problem Overview
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?
Git Solutions
Solution 1 - Git
Sure:
git diff A10..A1 > my.diff
Solution 2 - Git
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 - Git
From man page..
git format-patch -k --stdout R1..R2
Solution 4 - Git
If you just need save diff between two recent commits, you can use this command as well:
git diff HEAD^ HEAD > diff.txt
Solution 5 - Git
to get all folder/filenames as output from diff use
git diff <commit1> <commit2> --name-only