From 9608e4ace4cd36295893d0f398ac3aeefd09aed8 Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Wed, 30 Apr 2025 15:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B7=A5=E5=85=B7=E3=80=91=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tool/dll_tools/revert_and_pull_git.sh | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Tool/dll_tools/revert_and_pull_git.sh diff --git a/Tool/dll_tools/revert_and_pull_git.sh b/Tool/dll_tools/revert_and_pull_git.sh new file mode 100644 index 00000000000..0ce62904fff --- /dev/null +++ b/Tool/dll_tools/revert_and_pull_git.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# 自动还原git并拉取最新代码 +# 当前目录在C:/Work/Projects/NLDClient/Tool/dll_tools +# 需要操作目录在C:/Work/Projects/NLDClient + +# cd 到需要操作目录 +cd ../../ProjectNLD +# 检查是否进入成功 +if [ $? -ne 0 ]; then + echo "Failed to change directory to ProjectNLD" + exit 1 +fi + +# 检查当前目录是否是git仓库 +if [ ! -d ".git" ]; then + echo "Current directory is not a git repository" + exit 1 +fi + +# 还原所有修改 +git reset --hard HEAD +# 检查还原是否成功 +if [ $? -ne 0 ]; then + echo "Failed to reset git repository" + exit 1 +fi + +# 还原子模块的修改 +echo "Resetting submodules..." +git submodule foreach --recursive 'git reset --hard HEAD' +if [ $? -ne 0 ]; then + echo "Failed to reset some submodules" + exit 1 +fi + +# 拉取最新代码 +git pull +# 检查拉取是否成功 +if [ $? -ne 0 ]; then + echo "Failed to pull latest code from git" + exit 1 +fi + +# 更新子模块 +echo "Updating submodules..." +git submodule update --init --recursive +if [ $? -ne 0 ]; then + echo "Failed to update submodules" + exit 1 +fi + +# 输出结果 +echo "Git repository reset and pulled successfully" \ No newline at end of file