Windows 将git descripe设置为shell变量
我想根据Windows 将git descripe设置为shell变量,windows,git,shell,command-line,Windows,Git,Shell,Command Line,我想根据git descripe命令的输出创建一个目录 这不起作用: set NAME = git describe mkdir %NAME% 我该怎么办?在Windows上,您可以尝试上述方法 现在,如果您使用的是Linux,以下操作可能会起作用: 试试这个: # Create the command alias your-command="mkdir $(git describe)" # Run the command your-command 应创建一个名为的文件夹,其输出为git
git descripe
命令的输出创建一个目录
这不起作用:
set NAME = git describe
mkdir %NAME%
我该怎么办?在Windows上,您可以尝试上述方法 现在,如果您使用的是Linux,以下操作可能会起作用: 试试这个:
# Create the command
alias your-command="mkdir $(git describe)"
# Run the command
your-command
应创建一个名为的文件夹,其输出为git descripe
这是在ubuntu安装上测试的,它只能在存储库文件夹中工作
请注意,所述命令会创建别名。如果要将git descripe
的输出设置为shell变量,应执行以下操作:
# Create a local variable
foo=$(git describe)
# Create a new folder using `mkdir`
mkdir ${foo}
请注意,现在您有了一个值为git descripe
的局部变量。您可以尝试:
echo ${foo}
在Windows中,要捕获命令的输出,可以使用
FOR/F
命令
请阅读的帮助,然后尝试此操作
FOR /F %a in ('git describe') do md %a
你说得对,我没注意到标签。编辑澄清!这看起来解决了问题。我很好奇,如果使用Eval,它会工作吗?比如set NAME=Eval(git descripe)
。不幸的是,我的windows机器没有启动,所以我现在无法测试它。不管怎样,只是好奇而已。谢谢参考:Eval是一个VB函数,它不是Windows命令,因此不能在Windows命令行中执行。