Reputation: 3032
Lets assume I have a develop branch and I work in some feature branch, where I have one or more commits, I constantly amend commits as well as doing rebase of them with some other branches (to keep the commit history clean for future). At each stage I do diffs locally relative to the develop. So I have a set of diffs and I want to see the difference between them. How can I do that easily? What kind of git command sequence can I use?
Update
The solution is to have two diffs related to the develop. Have the copy of the repository in develop, apply first diff. Have anther copy and apply another patch. Use some comarison tool and compare two repositories. That would be the result that I expect. The problem with this approach is that I need to have at least two copies of the repository and use some tool to make a diff of directories. Another approach, which is probably better, is to use two branches, apply patches and commit changes, then compare branches. The question: is there something more simple in git commands to do that? Something like take this branch, and two diff files, return me diff?
Upvotes: 2
Views: 3126
Reputation: 7471
Your second workflow is the answer. Here is a possible alias:
diffdiff = !git stash save -u -q &&
git apply $1 && git add -A && git commit -q -m"1" &&
git reset --hard HEAD@{1} -q &&
git apply $2 && git add -A && git commit -q -m"2" &&
git reset --hard HEAD@{1} -q && git stash pop -q &&
git diff HEAD@{3} HEAD@{1} && :
Call it on the branch where you want to apply the diffs with diff files located outside of the repository.
git diffdiff <diff_file_1> <diff_file_2>
Not a multiplatform solution, tested on osx, with zsh and bash shells. If you are okay to do it manually it is quite a bit simpler, much of the complication here is to provide a kind-of-foolproof solution. Also the first line of output is noise, seems like git stash pop doesn't obey the --quiet parameter.
(Edit: There is no need for the temporary branch, so I simplified the alias.)
Upvotes: 5