Initialisation d’un dépôt
git init
git config user.name "Aminata Diop"
git config user.email "aminata@exemple.sn"
git remote add origin git@github.com:org/projet.git
# .gitignore minimal
cat > .gitignore << 'EOF'
node_modules/
.env
dist/
*.log
.DS_Store
EOF
Workflow de base (add / commit / push)
git status
git add src/ tests/
git diff --staged
git commit -m "feat(billing): calcul TVA 18% SYSCOHADA"
git push -u origin main
Branches et pull requests
git switch -c feat/export-pdf
# ... modifs ...
git add -A && git commit -m "feat: export facture PDF"
git push -u origin feat/export-pdf
# Via gh (GitHub CLI)
gh pr create --title "Export PDF factures" --body "Closes #142"
gh pr view --web
Récupérer les changements de l’équipe
git fetch origin
git status # indique: votre branche est en retard de N commits
git pull --rebase # rebase préféré à merge pour l'historique linéaire
# Conflit ? Git indique les fichiers en UU
git add fichier-resolu.js
git rebase --continue
Annuler une modification
# Dé-stager un fichier
git restore --staged fichier.js
# Annuler les modifs non commitées (destructif)
git restore fichier.js
# Revenir au commit précédent en gardant les modifs
git reset --soft HEAD~1
# Annuler un commit poussé (crée un commit inverse, sûr)
git revert <sha>
Historique et recherche
git log --oneline --graph --decorate --all | head -20
git log -p -- src/billing.js
git blame src/billing.js
git show HEAD~3
# Chercher dans tous les commits
git log -S "calculTVA" --oneline
git grep "TODO" $(git rev-list --all)
Stash : mettre de côté
git stash push -m "WIP: refactor users"
git switch main # intervention urgente
# ...
git switch feat/xxx
git stash pop
Tags et releases
git tag -a v1.2.0 -m "Release 1.2.0 - export PDF, i18n wolof"
git push --tags
# Via gh
gh release create v1.2.0 --notes-from-tag
gh release upload v1.2.0 dist/app.zip
Collaboration GitHub : forks et PR
gh repo fork org/projet --clone
cd projet
git switch -c fix/typo-readme
# ... modifs ...
git commit -am "docs: fix typo"
gh pr create
GitHub Actions minimale
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: "20", cache: "npm" }
- run: npm ci
- run: npm run lint
- run: npm test -- --coverage
Conventions de commits
feat: nouvelle fonctionnalité
fix: correction de bug
docs: documentation
refactor: refactor sans changement fonctionnel
test: ajout/modif tests
chore: maintenance, deps
feat(billing): ajoute acompte 30%
fix(auth): rejette les tokens expirés
BREAKING CHANGE: renomme /v1/ en /v2/
Besoin d'un site web ?
Confiez-nous la Création de Votre Site Web
Site vitrine, e-commerce ou application web — nous transformons votre vision en réalité digitale. Accompagnement personnalisé de A à Z.
À partir de 250.000 FCFA
Parlons de Votre Projet
Publicité