Bestehende Anwendung nach GitLab übernehmen

Schritte

  1. Per SSH auf den Server und in den Anwendungsordner wechseln.
ssh ids
cd /pfad/zur/anwendung
pwd
  1. 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
  1. .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
  1. Leeres Repo in GitLab erstellen.
  1. 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
  1. Deploy-Key in GitLab eintragen.
  1. 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
  1. Git initialisieren und ersten Stand committen.
git init
git add .
git status
git commit -m "chore: initial import"
  1. Backup-Branch erstellen und main setzen.
git branch backup-live
git branch -M main
  1. 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