Cosa otterrai
Alla fine di questo tutorial avrai forkato un repository open-source, fatto un piccolo cambiamento su un branch di feature, aperto una pull request, risposto al feedback e visto il tuo lavoro mergato.
Prerequisiti
- Git installato.
- Un account GitHub.
- Una chiave SSH o token configurato.
- Un repository target.
Passo 1: forkare il repository
git clone [email protected]:yourname/project.git
cd project
Passo 2: aggiungere upstream come remote
git remote add upstream [email protected]:original-owner/project.git
git remote -v
Passo 3: sincronizzare da upstream
git fetch upstream
git checkout main
git merge upstream/main --ff-only
git push origin main
Passo 4: creare un branch di feature
git checkout -b fix/typo-in-readme
Passo 5: fare il cambiamento
git status
git diff
git add README.md
git commit -m "Fix typo in installation section"
Passo 6: pushare il branch
git push -u origin fix/typo-in-readme
Passo 7: aprire la pull request
gh pr create --title "Fix typo in installation section" \
--body "Fixes a small typo where 'isntall' should read 'install'."
Passo 8: rispondere al feedback
git add CONTRIBUTING.md
git commit -m "Fix same typo in CONTRIBUTING"
git push
Passo 9: gestire fallimenti CI
Se la CI e rossa, click sulla run fallita.
Passo 10: merge
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
Insidie comuni dei nuovi arrivati
- Lavorare direttamente su
main. - Raggruppare modifiche non correlate in una PR.
- Pushare senza testare localmente.
- Force-push a
main.