我有一个设置批处理的问题。
我想进入我的项目目录,使用git fetch -all命令,切换到develop分支,执行pull操作,然后回到我的实际分支。
目前我已经成功地做到了这一点,但是使用变量检出分支是不可能的,我不知道为什么。
简而言之,我想要实现的是(在develop分支上):
set current_branch=custom
git checkout %current_branch%
这是完整的批处理文件
@echo off
SET project_array="c:\example\project01" "c:\example\project02"
for %%a in (%project_array%) do (
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo fetching datas for project at: %%a
cd %%a
@echo on
for /F "tokens=*" %%i in ('git branch --show-current') do set current_branch=%%i
git fetch --all
git checkout develop
git pull
git checkout %current_branch%
@echo off
)
PAUSE
%%i
分配给一个变量,而是直接使用它(git checkout %%i
)... - aschipfl