I'm trying to run git diff
to obtain only the deleted lines in the same file object.json
comparing my feature
branch to dev
branch.
For example:
feature branch object.json
{
"foo1": "bar1"
}
dev branch object.json
{
"foo1": "bar1",
"foo2": "bar2"
}
Desired output (or similar):
- "foo2": "bar2"
I've tried running the following:
git diff --diff-filter=D feature dev -- object.json
But the diff-filter
flag does not seem to work. Furthermore, it only gives a porcelain output which requires processing to be piped.
Is there a way I can achieve both filtering and converting this to plumbing with just git built-in options ? Any help is much appreciated!
CodePudding user response:
git diff feature:path/to/object.json dev:path/to/object.json \
| sed -n '/^@@/,/^diff/ { /^-/p }'
Git doesn't re-implement the entire Unix text-processing toolbox because doing that would just make more work for everyone, for nothing.