问题[吉特]
通过
[批处理]
假设我在“C:\RepoBase”中有一个git回购协议,以及其他可能的协议,但这是
主要的
回购我想违约。在不讨论进一步功能的情况下,脚本将CD发送到作为输入提供的位置,或者如果没有提供输入,则发送到默认路径,然后继续获取当前头提交的名称。
:: Go to the repo in question
if [%1]==[] (
cd C:\RepoBase
) else (
cd %1
)
:: Get name of current branch
FOR /F "tokens=*" %%g IN (
'call git rev-parse --abbrev-ref HEAD'
) do (
SET CurrentBranch=%%g
)
此解决方案
作品
为什么?
:: Go to the repo in question
SET PATH=%1
if [%1]==[] (
SET PATH=C:\RepoBase
)
cd "%PATH%"
:: Get name of current branch
FOR /F "tokens=*" %%g IN (
'call git rev-parse --abbrev-ref HEAD'
) do (
SET CurrentBranch=%%g
)