1
0
mirror of https://github.com/Oreomeow/VIP.git synced 2026-02-04 02:53:26 +08:00
Files
vip/Scripts/sh/gitsync.sh
2022-03-09 20:43:36 +08:00

44 lines
1.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# =========================
# git 同步脚本
#
# Author: 余小波
# Date: 2020-01-09
# =========================
# 本地文件是否发生了改变
is_change=$(git status -s)
# 当前分支
branch=$(git symbolic-ref --short -q HEAD)
# remark
if [ -n "$1" ]; then
guser=$1
else
# git.user.name
guser="$(git config user.name) update"
fi
if [ 0 -lt ${#is_change} ]; then
git add .
git commit -m "$guser"
# pull
result=$(git pull origin "$branch")
tmp=$(echo "$result" | grep "fix conflicts")
if [ "$tmp" != "" ]; then
echo "(=Д=)ノ┻━┻ 合并冲突, 请手动解决后提交"
else
# 推送
git push origin "$branch"
fi
else
echo "本地没有改变, 正在从远程仓库同步代码. 请耐心等待 ╭(●`∀´●)╯╰(●’◡’●)╮"
result=$(git pull origin "$branch")
tmp=$(echo "$result" | grep "fix conflicts")
if [[ "$tmp" != "" ]]; then
echo "(=Д=)ノ┻━┻ 合并冲突, 请手动解决后提交"
fi
fi