Most of the times I generate a diff file for my branches, like so: git diff trunk.. > .git/diffs/branch_name.diff
What I would like to do is change branch_name
to the output of git branch --show-current
.
I've tried doin something like git diff trunk.. > '.git/diffs/ $(git branch --show-current) .diff'
but that stores it with the filename literary as $(git branch --show-current) .diff
Is there a way for me to do this as a one liner?
CodePudding user response:
Unix shells ignore metacharacters inside single quotes (apostrophes). Use double quotes or no quotes:
git diff trunk.. > ".git/diffs/ $(git branch --show-current) .diff"
or
git diff trunk.. > .git/diffs/ $(git branch --show-current) .diff
PS. Some metacharacters are ignored in double quotes too. Most notable is *
. Compare echo *
and echo "*"