Ce que vous accomplirez
À la fin de ce tutoriel vous aurez forké un dépôt open-source, fait un petit changement sur une branche feature, ouvert une pull request, répondu au feedback, et vu votre travail mergé.
Prérequis
- Git installé.
- Un compte GitHub.
- SSH ou un personal access token configuré.
- Un dépôt cible.
Étape 1 : forker le dépôt
git clone [email protected]:yourname/project.git
cd project
Étape 2 : ajouter upstream comme remote
git remote add upstream [email protected]:original-owner/project.git
git remote -v
Étape 3 : sync depuis upstream
git fetch upstream
git checkout main
git merge upstream/main --ff-only
git push origin main
Étape 4 : créer une branche feature
git checkout -b fix/typo-in-readme
Étape 5 : faire le changement
git status
git diff
git add README.md
git commit -m "Fix typo in installation section"
Étape 6 : push de votre branche
git push -u origin fix/typo-in-readme
Étape 7 : ouvrir la pull request
gh pr create --title "Fix typo in installation section" \
--body "Fixes a small typo where 'isntall' should read 'install'."
Étape 8 : répondre au feedback
git add CONTRIBUTING.md
git commit -m "Fix same typo in CONTRIBUTING"
git push
Étape 9 : gérer les échecs de CI
Étape 10 : merger
gh pr merge --squash --delete-branch
git checkout main
git fetch upstream
git merge upstream/main --ff-only
git push origin main
git branch -d fix/typo-in-readme
Pièges courants pour débutants
- Travailler directement sur
main. - Empaqueter des changements non liés dans un PR.
- Pusher sans tester localement.
- Force-push sur
main.