24 lines
626 B
Bash
Executable File
24 lines
626 B
Bash
Executable File
#!/bin/bash
|
|
# Auto-commit and push script
|
|
# This script will be called after each commit
|
|
|
|
# Check if there are any changes to commit
|
|
if [[ $(git status --porcelain) ]]; then
|
|
echo "Found changes, committing and pushing..."
|
|
|
|
# Add all changes
|
|
git add .
|
|
|
|
# Get the current timestamp for the commit message
|
|
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
|
|
|
|
# Commit the changes
|
|
git commit -m "Auto-commit: $(hostname) - ${TIMESTAMP}"
|
|
|
|
# Push to remote repository
|
|
git push -u origin master
|
|
|
|
echo "Changes committed and pushed successfully!"
|
|
else
|
|
echo "No changes to commit."
|
|
fi |