Answer the question
In order to leave comments, you need to log in
How to write the execution of the git command in a string variable in a bat script?
It is necessary that when you run a bat file containing approximately: git log --pretty=format:"%%h" -1
The result of the execution is written to a string variable.
The following code doesn't work:
FOR /F "usebackq" %%a IN (' git log --pretty=format:"%%h" -1 ') DO (
set str1=%%a
)
echo %str1%
Answer the question
In order to leave comments, you need to log in
Read about SetLocal EnableDelayedExpansion, it seems to me that all your problems are related to it.
For example, in this example, everything was very similar
PS And as far as I understand, you wanted to glue, and inside the loop your variable is simply overwritten.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question