sync: 2026-09-28 19:21
This commit is contained in:
1 parent
fcb0e7abb3
commit
1794f795a5
2 files changed
+36
-3
No files matched your search
@@ -1,5 +1,2 @@
|
||||
# ignore update.sh script
|
||||
update.sh
|
||||
|
||||
# ignore C binairies
|
||||
*.out
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set PATH so cron can find git, date, ssh, etc.
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
|
||||
# Explicitly set target directory (don't rely on $HOME in cron)
|
||||
TARGET_DIR="/home/benji/Documents/COURS"
|
||||
|
||||
# If using SSH keys, specify the key for Git
|
||||
export GIT_SSH_COMMAND="ssh -i /home/benji/.ssh/git -o IdentitiesOnly=yes"
|
||||
|
||||
# Navigate to target directory
|
||||
cd "$TARGET_DIR" || {
|
||||
echo "Directory not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Pull remote changes rebase-style
|
||||
git pull --rebase --autostash || {
|
||||
echo "Git pull failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Stage all files
|
||||
git add -A
|
||||
|
||||
# Commit only if there are actual changes staged
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
git commit -m "sync: $(date +'%Y-%m-%d %H:%M')"
|
||||
git push || {
|
||||
echo "Git push failed"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo "No changes to commit."
|
||||
fi
|
||||
Reference in new issue
Block a user