Download fix_git_error.sh from gusmoon/TutorIA: direct link, hf CLI and curl.
- Browser
- Download file 4.23 kB
-
https://huggingface.co/spaces/gusmoon/TutorIA/resolve/main/fix_git_error.sh
- Command line
-
hf download hf://spaces/gusmoon/TutorIA/fix_git_error.sh
-
curl -L -o fix_git_error.sh https://huggingface.co/spaces/gusmoon/TutorIA/resolve/main/fix_git_error.sh
4.23 kB
| # Script para resolver error de Git push rechazado | |
| # Soluciona: ! [rejected] main -> main (fetch first) | |
| set -e | |
| # Colores | |
| GREEN='\033[0;32m' | |
| BLUE='\033[0;34m' | |
| RED='\033[0;31m' | |
| YELLOW='\033[1;33m' | |
| PURPLE='\033[0;35m' | |
| NC='\033[0m' | |
| print_status() { | |
| echo -e "${BLUE}[INFO]${NC} $1" | |
| } | |
| print_success() { | |
| echo -e "${GREEN}[SUCCESS]${NC} $1" | |
| } | |
| print_error() { | |
| echo -e "${RED}[ERROR]${NC} $1" | |
| } | |
| print_warning() { | |
| echo -e "${YELLOW}[WARNING]${NC} $1" | |
| } | |
| print_header() { | |
| echo -e "${PURPLE}$1${NC}" | |
| } | |
| print_header "🔧 Resolver Error Git Push" | |
| echo "==========================" | |
| # Verificar que estamos en un repositorio git | |
| if [ ! -d ".git" ]; then | |
| print_error "Este directorio no es un repositorio git" | |
| exit 1 | |
| fi | |
| print_status "Diagnosticando problema de Git..." | |
| # Verificar estado actual | |
| git_status=$(git status --porcelain) | |
| if [ -n "$git_status" ]; then | |
| print_warning "Hay cambios sin commit detectados" | |
| echo "$git_status" | |
| fi | |
| # Crear backup de seguridad | |
| backup_dir="backup_git_$(date +%Y%m%d_%H%M%S)" | |
| mkdir -p "$backup_dir" | |
| print_status "Creando backup de seguridad en $backup_dir/" | |
| # Backup de archivos importantes | |
| important_files=("app.py" "requirements.txt" "README.md") | |
| for file in "${important_files[@]}"; do | |
| if [ -f "$file" ]; then | |
| cp "$file" "$backup_dir/" | |
| print_success "✓ Backup de $file creado" | |
| fi | |
| done | |
| print_status "Intentando resolver conflicto de Git..." | |
| # Método 1: Pull simple | |
| print_status "Método 1: Intentando git pull..." | |
| if git pull origin main 2>/dev/null; then | |
| print_success "¡Pull exitoso! Intentando push..." | |
| if git push origin main 2>/dev/null; then | |
| print_success "¡Push exitoso! Problema resuelto." | |
| echo "" | |
| print_header "🎉 ¡Problema Resuelto!" | |
| echo "✅ Tu Space se está reconstruyendo automáticamente" | |
| echo "✅ Las correcciones de UI/UX se aplicarán en 1-2 minutos" | |
| exit 0 | |
| else | |
| print_warning "Push falló después del pull. Intentando método 2..." | |
| fi | |
| else | |
| print_warning "Pull falló. Probablemente hay conflictos. Intentando método 2..." | |
| fi | |
| # Método 2: Fetch y merge manual | |
| print_status "Método 2: Fetch y análisis de diferencias..." | |
| git fetch origin | |
| # Verificar diferencias | |
| print_status "Analizando diferencias entre local y remoto..." | |
| if git diff HEAD origin/main --quiet; then | |
| print_status "No hay diferencias de contenido. Problema de historial." | |
| # Forzar push | |
| read -p "¿Forzar push? Esto sobrescribirá cambios remotos (y/N): " -n 1 -r | |
| echo | |
| if [[ $REPLY =~ ^[Yy]$ ]]; then | |
| git push --force-with-lease origin main | |
| print_success "Push forzado exitoso" | |
| else | |
| print_error "Operación cancelada por el usuario" | |
| exit 1 | |
| fi | |
| else | |
| print_warning "Hay diferencias de contenido. Resolviendo..." | |
| # Intentar merge automático | |
| if git merge origin/main --no-edit 2>/dev/null; then | |
| print_success "Merge automático exitoso" | |
| if git push origin main; then | |
| print_success "Push exitoso después del merge" | |
| else | |
| print_error "Push falló después del merge" | |
| exit 1 | |
| fi | |
| else | |
| print_error "Conflictos de merge detectados" | |
| print_status "Archivos con conflictos:" | |
| git diff --name-only --diff-filter=U | |
| echo "" | |
| print_warning "ACCIÓN REQUERIDA:" | |
| echo "1. Resuelve los conflictos manualmente en los archivos listados" | |
| echo "2. Busca marcadores: <<<<<<< HEAD, =======, >>>>>>> origin/main" | |
| echo "3. Edita los archivos para mantener el código correcto" | |
| echo "4. Ejecuta:" | |
| echo " git add ." | |
| echo " git commit -m 'Resolver conflictos UI/UX'" | |
| echo " git push origin main" | |
| echo "" | |
| print_status "Backup disponible en: $backup_dir/" | |
| exit 1 | |
| fi | |
| fi | |
| print_header "🎉 ¡Problema Resuelto!" | |
| echo "" | |
| echo "✅ Git push exitoso" | |
| echo "✅ Tu Space se está reconstruyendo automáticamente" | |
| echo "✅ Las correcciones de UI/UX se aplicarán en 1-2 minutos" | |
| echo "" | |
| echo "💾 Backup guardado en: $backup_dir/" | |
| echo "" | |
| print_success "¡Problema de Git resuelto exitosamente!" | |