#!/usr/bin/env bash set -e BRANCH="main" # Stop if not inside a git repo git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "Not inside a git repository." exit 1 } # Check if there are changes if [ -z "$(git status --porcelain)" ]; then echo "No changes to commit." exit 0 fi # Random commit message MSG="update-$(date +%Y%m%d-%H%M%S)-$RANDOM" echo "Using commit message: $MSG" git add . git commit -m "$MSG" git push origin "$BRANCH" echo "Done."