Add pib
This commit is contained in:
commit
cae3cad034
1 changed files with 47 additions and 0 deletions
47
pib
Normal file
47
pib
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check if the repository URL is provided
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <remote_repo_url>"
|
||||
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
|
Loading…
Reference in a new issue