# Script simple para hacer commits de a 100 archivos | |
# Uso: ./simple_batch_commit.sh "mensaje del commit" | |
if [ $# -eq 0 ]; then | |
echo "Uso: $0 \"mensaje del commit\"" | |
exit 1 | |
fi | |
COMMIT_MESSAGE="$1" | |
BATCH_SIZE=100 | |
counter=0 | |
echo "Iniciando commits en lotes de $BATCH_SIZE archivos..." | |
# Obtener lista de archivos modificados (sin espacios al inicio) | |
files=$(git status --porcelain | sed 's/^...//') | |
# Contar total de archivos | |
total_files=$(echo "$files" | wc -l) | |
echo "Total de archivos a procesar: $total_files" | |
# Procesar archivos en lotes | |
echo "$files" | while IFS= read -r file; do | |
if [ -n "$file" ]; then | |
git add "$file" | |
counter=$((counter + 1)) | |
# Si llegamos a 100 archivos, hacer commit | |
if [ $((counter % BATCH_SIZE)) -eq 0 ]; then | |
batch_num=$((counter / BATCH_SIZE)) | |
echo "Haciendo commit del lote $batch_num (archivos $((counter - BATCH_SIZE + 1))-$counter)..." | |
git commit -m "$COMMIT_MESSAGE (lote $batch_num: $BATCH_SIZE archivos)" | |
fi | |
fi | |
done | |
# Commit final con los archivos restantes | |
remaining=$((counter % BATCH_SIZE)) | |
if [ $remaining -gt 0 ]; then | |
echo "Haciendo commit final de $remaining archivos..." | |
git commit -m "$COMMIT_MESSAGE (lote final: $remaining archivos)" | |
fi | |
echo "¡Todos los commits completados!" |