Windows脚本导出git当前分支信息

@echo off
::这里填写git目标目录
cd E:/webrtc/src

::导出时间
for /F %%i in ('powershell -c "(Get-Date -Format 'yyyyMMdd_HHmmss')"') do ( set PACKAGE_TIME=%%i)

::导出分支信息
for /F %%i in ('git name-rev --name-only HEAD') do ( set GIT_BRANCH=%%i)
::去除斜杠,避免拷贝报错
set "GIT_BRANCH=%GIT_BRANCH:remotes/=%"
set "GIT_BRANCH=%GIT_BRANCH:/=_%"

::导出分钟提交时间-MD5值
for /F %%i in ('git show --oneline --pretty^=format:"%%cd_%%h" --date^=format:"%%Y%%m%%d_%%H%%M%%S" -s HEAD') do ( set GIT_TIME=%%i)

::这里填写导入的文件名
echo %PACKAGE_TIME%>E:/WebrtcVersion
echo %GIT_BRANCH%>>E:/WebrtcVersion
echo %GIT_TIME%>>E:/WebrtcVersion

pause

你可能感兴趣的:(Git,windows,git)