Bat 建立git分支tag並推送

2022-01-30 13:32:45 字數 1644 閱讀 2423

方便版本更新以後,給各個專案打tag並推送。設定分支、標籤資訊以後,可多次呼叫函式,給多個專案打標籤。

@echo off

@title 新建標籤

::set /p branchname=請輸入分支名稱:

::echo %description%

rem set /p branchname=r4.2

rem set /p tagname=請輸入標籤名稱:

rem echo %tagname%

rem set /p description=請輸入描述名稱:

rem echo %description%

set branchname=r4.7_mainservice

set tagname=tag_r4.7_mainservice_hc_0113

set description="2023年01月13日 凌晨,r4.7_mainservice版本更新hc伺服器"

rem call:createtag e:\git\lxwebsite %branchname% %tagname% %description%

call:createtag e:\git\lxservice %branchname% %tagname% %description%

call:createtag e:\git\lxwebapi %branchname% %tagname% %description%

call:createtag e:\git\ylpt-lixin-database %branchname% %tagname% %description%

echo\&echo done...

pause

exit

:: 切換分支 par1根目錄 par2目標分支 par3標籤名稱 par4標籤描述

:createtag

:: 0.切換根目錄

cd /d %1

:: 1.切換到目標分支

git checkout %2

if not %errorlevel%==0 (

echo 切換到%2分支出現問題。新開視窗解決完錯誤後,繼續……

"c:\program files\git\git-bash.exe"

):: 2.獲取最新**

git pull

if not %errorlevel%==0 (

echo 獲取最新**出現問題。新開視窗解決完錯誤後,繼續……

"c:\program files\git\git-bash.exe"

):: 3.建立標籤

git tag -a %3 -m %4

if not %errorlevel%==0 (

echo 建立標籤出現問題。新開視窗解決完錯誤後,繼續……

"c:\program files\git\git-bash.exe"

):: 3.推送標籤

git push origin %3

if not %errorlevel%==0 (

echo 推送標籤出現問題。新開視窗解決完錯誤後,繼續……

"c:\program files\git\git-bash.exe"

)goto:eof

git 根據tag建立分支

在專案中我們需要根據tag建立分支.現將建立步驟總結一下.假設在你的主分支上有乙個tag為v1.0,主分支的名字為master.1.執行 git origin fetch 獲得最新.2.通過 git branch new branch name tag name 會根據tag建立新的分支.例如 gi...

git 根據tag建立分支

git 根據tag建立分支 在專案中我們需要根據tag建立分支.現將建立步驟總結一下.假設在你的主分支上有乙個tag為v1.0,主分支的名字為master.1.執行 git origin fetch 獲得最新.2.通過 git branch new branch name tag name 會根據t...

git 分支管理,新增tag

本地 stage 暫存 配置全域性使用者 郵箱 git config global user.name jerry git config global user.email jerry 163.com git commmit 提交注釋 新倉庫建立dev分支 git checkout b dev st...