1

My command is to pull log from repository based on a previous tag till the latest HEAD. Below is the command i run in powershell

git log 10.01.39.000..head --oneline --name-only --pretty=format:

The same when i try to do it by substituting a variable in place of the tag name does not give me the output. Should the .. be escaped in powershell? Powershell is considering the ..Head as a method for the variable.

git log $tag..head --oneline --name-only --pretty=format:
3
  • 1
    You should try either "$tag..HEAD" or "$($tag)..HEAD", one of those should work, but you should include the double quotes, otherwise Powershell might separate on .. and add some spaces (has been my experience) Commented Jan 6, 2022 at 10:00
  • "$tag..HEAD" worked for me. Thanks Commented Jan 6, 2022 at 10:18
  • Also, you should in general get in the habit of typing HEAD in all caps, or use its one-character synonym @. Lowercase head sometimes works and sometimes doesn't, and when it doesn't, the result can be pretty bad sometimes. Commented Jan 6, 2022 at 19:49

1 Answer 1

4

In this case, you want to:

  • Force expansion of $tag before passing the argument to git
  • Prevent evaluation of the .. operator

The easiest way to do this is to construct an expandable string literal using ":

git log "$tag..head" --oneline --name-only --pretty=format:...
Sign up to request clarification or add additional context in comments.

1 Comment

This saved me further days in debugging azure pipeline scripts!

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.