#!/usr/bin/env bash # Define the branch name BRANCH_NAME=dev # Check if the branch exists locally if git rev-parse --verify $BRANCH_NAME > /dev/null 2>&1; then # Get commit message # message=$(git diff | ~/scripts/shelly 'write a short git commit message for this diff') message="$(date --iso-8601=seconds)" echo $message # Add and commit changes git add . git commit -m "$message" # Pull the latest changes from the main branch to ensure we're up to date git pull origin main # Push the changes to the remote branch named dev_$(hostname) git push origin $BRANCH_NAME # Merge to main git switch main git merge dev git commit git push # Switch to the branch git switch $BRANCH_NAME else echo "Branch $BRANCH_NAME does not exist locally!" exit 1 fi