'Generic git diff alias for merge-base
I'm looking to create an alias that takes a diff between the merge base of a branch and origin/HEAD. Ideally, I'd be able to write something like:
[alias]
hd = diff origin/HEAD...
however, that ends up being expanded out to this:
git diff origin/HEAD... branchname
The problem there is the space between ... and branchname causes a different result than I'm looking for. I can invoke this as:
[alias]
hd = "!git diff origin/HEAD...$@"
and get what I'm looking for, however, that breaks things like --name-only for:
git hd --name-only
unless I explicitly write HEAD and put the arguments later:
git hd HEAD --name-only
Is there a way to write this alias that works and still allows for typical ordering of flags?
It looks like something hd = diff --merge-base origin/HEAD would probably work, but I'm stuck on 2.25, currently.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
