primera subida
This commit is contained in:
@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "📁 Ingresá el directorio del proyecto:"
|
||||
read -r PROJECT_DIR
|
||||
|
||||
if [ ! -d "$PROJECT_DIR" ]; then
|
||||
echo "❌ El directorio no existe. Abortando."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$PROJECT_DIR" || exit
|
||||
|
||||
# Inicializar Git si no existe
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "🔧 Inicializando repositorio Git local..."
|
||||
git init
|
||||
git branch -m main
|
||||
fi
|
||||
|
||||
# Agregar archivos
|
||||
git add .
|
||||
|
||||
echo "📝 Ingresá el mensaje del commit:"
|
||||
read -r COMMIT_MSG
|
||||
|
||||
git commit -m "$COMMIT_MSG"
|
||||
|
||||
# Configurar remoto
|
||||
echo "🌐 Ingresá la URL del repositorio remoto en Gitea (HTTPS):"
|
||||
read -r REMOTE_URL
|
||||
|
||||
git remote remove origin 2>/dev/null
|
||||
git remote add origin "$REMOTE_URL"
|
||||
|
||||
# Autenticación
|
||||
echo "🔐 Ingresá tu usuario de Gitea:"
|
||||
read -r USER
|
||||
|
||||
echo "🔐 Ingresá tu contraseña o token de Gitea:"
|
||||
read -rs PASS
|
||||
|
||||
# Push
|
||||
echo "🚀 Subiendo archivos..."
|
||||
git push -u https://"$USER":"$PASS"@"${REMOTE_URL#https://}" main
|
100
instalar-subir.sh
Executable file
100
instalar-subir.sh
Executable file
@ -0,0 +1,100 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ╔════════════════════════════════════════════════════╗
|
||||
# ║ VERIFICACIÓN DE REPOSITORIO GIT ║
|
||||
# ╚════════════════════════════════════════════════════╝
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
||||
echo ""
|
||||
echo "🛑 Este comando debe ejecutarse dentro de un repositorio Git."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BRANCH="main"
|
||||
|
||||
# ╔════════════════════════════════════════════════════╗
|
||||
# ║ INGRESO DE CREDENCIALES ║
|
||||
# ╚════════════════════════════════════════════════════╝
|
||||
|
||||
echo ""
|
||||
echo "🔐 Ingresá tu usuario de Gitea:"
|
||||
echo "╔════════════════╗"
|
||||
read -p "║ Usuario: " USER
|
||||
echo "╚════════════════╝"
|
||||
|
||||
echo ""
|
||||
echo "🔐 Ingresá tu contraseña o token de Gitea:"
|
||||
echo "╔════════════════════════════════╗"
|
||||
read -s -p "║ Contraseña/Token: " TOKEN
|
||||
echo ""
|
||||
echo "╚════════════════════════════════╝"
|
||||
|
||||
# ╔════════════════════════════════════════════════════╗
|
||||
# ║ DETECCIÓN DE CAMBIOS SIN COMMITEAR ║
|
||||
# ╚════════════════════════════════════════════════════╝
|
||||
|
||||
CHANGES=$(git status --porcelain)
|
||||
|
||||
if [ -n "$CHANGES" ]; then
|
||||
echo ""
|
||||
echo "📦 Se detectaron cambios sin commitear:"
|
||||
echo "$CHANGES"
|
||||
read -p "¿Querés hacer commit automático de estos cambios? (s/n): " COMMIT_RESP
|
||||
|
||||
if [ "$COMMIT_RESP" == "s" ]; then
|
||||
echo ""
|
||||
read -p "📝 Ingresá el mensaje de commit: " COMMIT_MSG
|
||||
git add .
|
||||
git commit -m "$COMMIT_MSG"
|
||||
echo "✅ Commit realizado."
|
||||
else
|
||||
echo "🛑 No se hizo commit. Continuando sin cambios."
|
||||
fi
|
||||
fi
|
||||
|
||||
# ╔════════════════════════════════════════════════════╗
|
||||
# ║ INICIO DE SUBIDA DE ARCHIVOS ║
|
||||
# ╚════════════════════════════════════════════════════╝
|
||||
|
||||
echo ""
|
||||
echo "🚀 Subiendo archivos al repositorio remoto..."
|
||||
echo ""
|
||||
|
||||
REPO_URL=$(git config --get remote.origin.url)
|
||||
|
||||
git config --global credential.helper store
|
||||
echo "${REPO_URL/https:\/\//https://$USER:$TOKEN@}" > ~/.git-credentials
|
||||
|
||||
git push origin $BRANCH
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "⚠️ Push fallido. Intentando pull con --allow-unrelated-histories..."
|
||||
git pull origin $BRANCH --allow-unrelated-histories
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "✅ Pull exitoso. Reintentando push..."
|
||||
git push origin $BRANCH
|
||||
else
|
||||
echo ""
|
||||
echo "⚠️ Verificando conflictos..."
|
||||
CONFLICTS=$(git diff --name-only --diff-filter=U)
|
||||
|
||||
if [ -n "$CONFLICTS" ]; then
|
||||
echo ""
|
||||
echo "🚨 Conflictos detectados:"
|
||||
echo "$CONFLICTS"
|
||||
read -p "¿Hacer merge automático? (s/n): " RESP
|
||||
if [ "$RESP" == "s" ]; then
|
||||
git add .
|
||||
git commit -m "🔀 Merge automático"
|
||||
git push origin $BRANCH
|
||||
echo "🎉 Push completado después del merge."
|
||||
else
|
||||
echo "🛑 Merge cancelado. Resolvé manualmente."
|
||||
fi
|
||||
else
|
||||
echo "❌ Pull falló por otro motivo."
|
||||
fi
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user