23 lines
701 B
Bash
Executable File
23 lines
701 B
Bash
Executable File
#!/bin/bash
|
|
# Sync project to receiver machine via rsync
|
|
# Usage: ./sync.sh [user@host] [remote_path]
|
|
set -euo pipefail
|
|
|
|
REMOTE="${1:-mariano@mcrndeb}"
|
|
REMOTE_PATH="${2:-~/wdir/cht/}"
|
|
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
# Ask git directly what it ignores — more reliable than rsync's .gitignore parsing,
|
|
# and correctly reflects the current branch after a checkout.
|
|
EXCLUDE_FILE=$(mktemp)
|
|
trap "rm -f '$EXCLUDE_FILE'" EXIT
|
|
|
|
git -C "$PROJECT_DIR" ls-files --others --ignored --exclude-standard --directory \
|
|
> "$EXCLUDE_FILE" 2>/dev/null || true
|
|
|
|
rsync -avz --delete \
|
|
--exclude='.git/' \
|
|
--exclude-from="$EXCLUDE_FILE" \
|
|
"$PROJECT_DIR/" \
|
|
"${REMOTE}:${REMOTE_PATH}"
|