Voici la version prête à copier dans ton dépôt GitLab, nomme-la GIT_SYNC_GUIDE.md :
# 🧭 Guide interne — Synchronisation GitLab ↔ GitHub
> Document privé – à ne **pas** publier sur GitHub
> Auteur : Bennirah
> Projet : DevOps API Deploy
---
## 📂 Structure logique
- **GitLab** = dépôt principal (privé, CI/CD réel)
- **GitHub** = miroir public (portfolio, vitrine)
---
## ⚙️ Configuration initiale
```bash
# Remote GitLab déjà configuré
origin git@gitlab.com:bennirah/api-ansible.git
# Ajouter le miroir GitHub
git remote add github git@github.com:bennirahh/devops-api-deploy.gitgit checkout public
# modifications
git add -A
git commit -m "feat: mise à jour pipeline"git pushgit push github public:main
git push github --tags(Le :main conserve le nom de branche GitHub par défaut.)
git remote -v # afficher les remotes
git branch -vv # voir le suivi (upstream)
git status # état du répertoire
git log --oneline -5 # derniers commitsgit config alias.publish '!git push && git push github public:main && git push github --tags'
# utilisation :
git publish- Toujours pousser d’abord sur GitLab (source fiable).
- Ne jamais supprimer la branche
public. - Protéger
publicetmaindans GitLab. - Aucun secret ni clé dans le code GitHub.
- Garder GitHub comme vitrine technique claire.
| Problème | Solution |
|---|---|
no upstream branch |
git push --set-upstream origin public |
Permission denied (publickey) |
Ajouter ta clé SSH sur GitHub / GitLab |
repository not found |
Vérifie git remote -v |
| Changer l’URL GitHub | git remote set-url github <nouvelle_url> |
- GitLab → source principale, CI/CD complet.
- GitHub → miroir public et vitrine pro.
- Branche unique :
public, poussée sur les deux remotes.
Ce fichier restera purement interne, versionné uniquement dans ton GitLab.