Bestehende Anwendung nach GitLab übernehmen
Schritte
- Per SSH auf den Server und in den Anwendungsordner wechseln.
ssh ids
cd /pfad/zur/anwendung
pwd
- Alte Sicherungsdateien prüfen und entfernen.
find . -type f \( -name "*.save" -o -name "*.bak" -o -name "*.old" -o -name "*~" -o -name "*.zip" -o -name "*.tar.gz" \) -print
# erst nach Prüfung löschen:
find . -type f \( -name "*.save" -o -name "*.bak" -o -name "*.old" -o -name "*~" -o -name "*.zip" -o -name "*.tar.gz" \) -delete
.gitignore anlegen und bei Bedarf anpassen.
cat > .gitignore <<'EOF'
*.save
*.bin
*.env
*.code-workspace
*.log
*.sql
*.txt
*.tar.gz
*.zip
*.dat
*.csv
.git/*
php.ini
sess_*
.vscode/*
Dockerfile
docker-compose.yaml
xdebug.ini
php-docker.sh
extshops/*
vendor/
temp/
!temp/cron/
temp/cron/*
system/
EOF
- Leeres Repo in GitLab erstellen.
- GitLab > New project > Create blank project
- Gruppe und Projektname wählen
- README nicht erstellen
- SSH-URL kopieren, z. B.
git@gitlab.com:gruppe/projekt.git
- Deploy-Key auf dem Server prüfen oder erstellen.
ls -l ~/.ssh/*.pub
# wenn kein passender GitLab-Key existiert:
ssh-keygen -t ed25519 -C "deploy $(hostname):projekt" -f ~/.ssh/gitlab-projekt
cat ~/.ssh/gitlab-projekt.pub
- Deploy-Key in GitLab eintragen.
- Repo > Settings > Repository > Deploy keys
- Public Key vom Server einfügen
- Write access allowed aktivieren, wenn der Server pushen soll
- SSH-Key auf dem Server mit GitLab verbinden.
cat >> ~/.ssh/config <<'EOF'
Host gitlab-projekt
HostName gitlab.com
User git
IdentityFile ~/.ssh/gitlab-projekt
IdentitiesOnly yes
EOF
chmod 600 ~/.ssh/config
ssh -T git@gitlab-projekt
- Git initialisieren und ersten Stand committen.
git init
git add .
git status
git commit -m "chore: initial import"
- Backup-Branch erstellen und
main setzen.
git branch backup-live
git branch -M main
- GitLab verbinden und beide Branches pushen.
# mit Host-Alias aus Schritt 7:
git remote add origin git@gitlab-projekt:gruppe/projekt.git
# sonst normale GitLab-SSH-URL verwenden:
# git remote add origin git@gitlab.com:gruppe/projekt.git
git push -u origin backup-live
git push -u origin main