Reputation: 16287
When I call git from a PowerShell script I start to run into problems when I run more complex commands:
# Work fine
git log
# Gives error
git log `git describe --tags --abbrev=0 HEAD^`..HEAD --oneline --count
Error:
fatal: ambiguous argument 'git': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Is there a good way to encapsulate these long commands when calling them from PowerShell?
Upvotes: 3
Views: 1931
Reputation: 5938
You can use $()
to perform the substitution within a string to get this to work.
git log "$(git describe --tags --abbrev=0 HEAD^)..HEAD" --oneline --count
The backtick character is used as an escape character in PowerShell much like backslash is used in Unix shells.
Upvotes: 2