I'm trying to summarize the difference between an "old" and "new" state of the codebase.
Ideally, I'd like to get the output of "git diff" where all the "+" and "-" lines would be annotated with information about commits which last introduced these changes; ideally, in a git pretty format (e.g. hash, author and date).
How can this be achieved?
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.
From git-blame: Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision. When specified one or more times, -L restricts annotation to the requested lines.
The diff can be done with git diff (followed by the filename or nothing if you want to see the diff of all modified files). But if you already did something like git add * , you have to undo with git restore --staged . first.
You could write a small script which does something like
git blame before > before git blame after > after diff -u before after
:)
See man 1 git
re: GIT_EXTERNAL_DIFF
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With