You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6.5 KiB
6.5 KiB
Guida: Inizializzazione Repository e Push a Gitea
Prerequisiti
- Git installato e configurato
- Token API di Gitea generato da https://git.enne2.net/user/settings/applications
- SSH key configurata per l'accesso a Gitea
- Accesso al terminale nella directory del progetto
Passo 1: Inizializzare il Repository Locale
git init
Questo crea la cartella .git nella directory corrente. Il .gitignore deve essere già presente e configurato.
Passo 2: Creare la Repository su Gitea tramite API
Opzione A: Usando variabili d'ambiente (Consigliato)
# Imposta le variabili
TOKEN="d44ab7c80e14952bcb8a573ef2d909a2dc176668"
REPO_NAME="playwright-form-automation"
GITEA_URL="https://git.enne2.net"
REPO_DESCRIPTION="Sistema completo per automatizzare submit di form su siti web usando Playwright"
# Crea la repository
curl -X POST "${GITEA_URL}/api/v1/user/repos" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"${REPO_NAME}\",
\"description\": \"${REPO_DESCRIPTION}\",
\"private\": false,
\"auto_init\": false
}"
Opzione B: Comando diretto
curl -X POST "https://git.enne2.net/api/v1/user/repos" \
-H "Authorization: token d44ab7c80e14952bcb8a573ef2d909a2dc176668" \
-H "Content-Type: application/json" \
-d '{
"name": "playwright-form-automation",
"description": "Sistema per automatizzare submit di form su siti web usando Playwright",
"private": false,
"auto_init": false
}'
Output atteso: JSON con i dettagli della repository creata (incluso l'SSH URL)
Opzione C: Creare manualmente su Gitea
Se preferisci:
- Accedi a https://git.enne2.net/
- Clicca su "+" → "New Repository"
- Inserisci il nome e fai click su "Create Repository"
- Importante: Assicurati che sia vuota (no auto-init)
Passo 3: Aggiungere i File al Staging
git add .
Verifica che i file corretti siano stati aggiunti:
git status
Dovresti vedere tutti i file tranne quelli in .gitignore (node_modules, page-dumps ecc).
Passo 4: Creare il Primo Commit
git commit -m "Initial commit: Playwright form automation system"
Oppure con descrizione più dettagliata:
git commit -m "Initial commit: Playwright form automation system
- Page dumping system for debugging
- Form element handling
- Login automation with fallback
- Comprehensive error handling"
Passo 5: Configurare il Remote SSH
git remote add origin ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git
Verifica che il remote sia stato aggiunto correttamente:
git remote -v
Output atteso:
origin ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git (fetch)
origin ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git (push)
Passo 6: Fare il Push del Codice
git push -u origin master
Output atteso:
Enumerazione degli oggetti in corso: 10, fatto.
Conteggio degli oggetti in corso: 100% (10/10), fatto.
...
To ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
Verificazione
- Visita https://git.enne2.net/enne2/playwright-form-automation
- Verifica che i file siano visibili
- Controlla il log dei commit
Comandi Futuri
Dopo il primo push, per i commit successivi:
# Effettuare modifiche ai file...
# Aggiungere i file modificati
git add .
# Creare un commit
git commit -m "Descrizione delle modifiche"
# Fare il push
git push origin master
Visualizzare la cronologia:
git log --oneline
Tirare gli ultimi cambiamenti da remoto:
git pull origin master
Troubleshooting
Errore: "SSH key not found"
Soluzione: Configura la tua SSH key:
ssh-keygen -t ed25519 -C "me@enne2.net"
ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 222 git@git.enne2.net
Errore: "fatal: .git is not a repository"
Soluzione: Esegui git init nella directory corretta
Errore: "remote: Repository not found"
Soluzione:
- Verifica che la repository esista su Gitea
- Controlla l'SSH URL (incluso il nome utente e il numero di porta 222)
Errore: "Your branch and 'origin/master' have diverged"
Soluzione:
git pull origin master --rebase
git push origin master
Variabili Comuni
| Variabile | Valore | Note |
|---|---|---|
TOKEN |
d44ab7c80e14952bcb8a573ef2d909a2dc176668 |
Token API personale |
GITEA_URL |
https://git.enne2.net |
URL base di Gitea |
SSH_HOST |
git@git.enne2.net |
Host SSH |
SSH_PORT |
222 |
Porta SSH custom |
REPO_NAME |
playwright-form-automation |
Nome della repository |
USERNAME |
enne2 |
Username di Gitea |
Script Automatico
Puoi creare uno script bash per automatizzare tutto il processo:
File: setup-gitea-repo.sh
#!/bin/bash
# Variabili di configurazione
TOKEN="d44ab7c80e14952bcb8a573ef2d909a2dc176668"
GITEA_URL="https://git.enne2.net"
SSH_HOST="git@git.enne2.net"
SSH_PORT="222"
USERNAME="enne2"
REPO_NAME="${1:-playwright-form-automation}"
REPO_DESC="${2:-Playwright Form Automation System}"
echo "📦 Inizializzazione repository: $REPO_NAME"
# Step 1: git init
echo "1️⃣ Inizializzando repository locale..."
git init
# Step 2: Crea repository su Gitea
echo "2️⃣ Creando repository su Gitea..."
RESPONSE=$(curl -s -X POST "${GITEA_URL}/api/v1/user/repos" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"name\": \"${REPO_NAME}\", \"description\": \"${REPO_DESC}\", \"private\": false, \"auto_init\": false}")
if echo "$RESPONSE" | grep -q "\"name\":\"${REPO_NAME}\""; then
echo "✅ Repository creata su Gitea"
else
echo "❌ Errore nella creazione della repository"
echo "$RESPONSE"
exit 1
fi
# Step 3: git add
echo "3️⃣ Aggiungendo file..."
git add .
# Step 4: git commit
echo "4️⃣ Creando commit iniziale..."
git commit -m "Initial commit: $REPO_DESC"
# Step 5: git remote
echo "5️⃣ Configurando remote SSH..."
git remote add origin "ssh://${SSH_HOST}:${SSH_PORT}/${USERNAME}/${REPO_NAME}.git"
# Step 6: git push
echo "6️⃣ Facendo push del codice..."
git push -u origin master
echo "✨ Repository sincronizzata!"
echo "📍 URL: ${GITEA_URL}/${USERNAME}/${REPO_NAME}"
Utilizzo:
chmod +x setup-gitea-repo.sh
./setup-gitea-repo.sh "nome-repo" "Descrizione del progetto"
Creato: 25 ottobre 2025
Ultimo aggiornamento: 25 ottobre 2025