【工具】更新工具
parent
f248f885cd
commit
9608e4ace4
|
|
@ -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"
|
||||||
Loading…
Reference in New Issue