Skip to content

Instantly share code, notes, and snippets.

@bivex
Created January 11, 2026 01:50
Show Gist options
  • Select an option

  • Save bivex/525f7961c63d0e338887618a4e9445f4 to your computer and use it in GitHub Desktop.

Select an option

Save bivex/525f7961c63d0e338887618a4e9445f4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Fast Git commit script
# Creates new branch based on Unix timestamp
# Stages all changes (including deletions)
# Skips commit if nothing changed
# Uses timestamped commit message
set -e
# Go to repo root (optional safety)
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || {
echo "❌ Not inside a git repository"
exit 1
}
cd "$REPO_ROOT"
# Create new branch with Unix timestamp
BRANCH_NAME="branch_$(date +%s)"
echo "πŸ“ Creating and switching to new branch: $BRANCH_NAME"
git checkout -b "$BRANCH_NAME"
# Stage everything (add / modify / delete)
git add -A
# Check if there is anything to commit
if git diff --cached --quiet; then
echo "βœ” Nothing to commit, working tree clean"
exit 0
fi
# Commit with timestamp
COMMIT_MSG="fast commit on $BRANCH_NAME - $(date '+%Y-%m-%d %H:%M:%S')"
git commit -m "$COMMIT_MSG"
echo "βœ… Commit created on branch $BRANCH_NAME: $COMMIT_MSG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment