#!/bin/sh # Check if the repository URL is provided if [ -z "$1" ]; then echo "Usage: $0 " exit 1 fi # Set the remote repository URL from the first positional argument REMOTE_REPO="$1" # Get the list of all commit hashes commits=$(git rev-list --reverse main) # Set the batch size BATCH_SIZE=1000 # Initialize counter and range variables start=0 end=$BATCH_SIZE # Convert commits to an array commit_array=($commits) # Get the total number of commits total_commits=${#commit_array[@]} # Push commits in batches while [ $start -lt $total_commits ] do # Determine the end of the current batch if [ $end -gt $total_commits ]; then end=$total_commits fi # Get the range of commits for the current batch range="${commit_array[$end-1]}" # Push the current batch git push $REMOTE_REPO $range:refs/heads/main -f # Update the start and end for the next batch start=$end end=$(($end + $BATCH_SIZE)) done