commit_uploads.sh 925 Bytes
#!/bin/bash
# 提交本地所有改动到远程仓库
# 用法: bash commit_uploads.sh [commit message]
set -e

MSG="${1:-chore: update $(date '+%Y-%m-%d %H:%M')}"

echo "========================================="
echo "  1. 提交所有改动"
echo "========================================="
git add -A

if git diff --cached --quiet; then
    echo "    没有需要提交的变更,跳过"
else
    echo "    变更文件:"
    git diff --cached --name-only
    git commit -m "$MSG"
    echo "    提交完成"
fi

echo ""
echo "========================================="
echo "  2. pull --rebase"
echo "========================================="
git pull --rebase

echo ""
echo "========================================="
echo "  3. push"
echo "========================================="
git push

echo ""
echo "========================================="
echo "  完成!"
echo "========================================="