3

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?

1
  • 1
    Are you certain that the inner command, git describe --tags --abbrev=0 HEAD^, works by itself? Commented Jan 29, 2016 at 11:13

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.