Da Anonimo (non verificato) , 29 Aprile 2026

Cosa otterrai

Configurerai un repository Git condiviso con protezione branch, un workflow predefinito pulito, hook per qualita codice e integrazione CI.

Passo 1: creare il repository

git clone [email protected]:myorg/project.git
cd project

Passo 2: configurare il branch predefinito

git config init.defaultBranch main

Passo 3: protezione branch

  • Richiedere una pull request prima del merge.
  • Richiedere almeno una review approvante.
  • Richiedere status check.
  • Richiedere storia lineare.
  • Vietare force push.
  • Vietare cancellazione diretta.

Passo 4: .gitignore e .gitattributes

# .gitignore
node_modules/
dist/
.env*
!.env.example
.DS_Store
*.swp

# .gitattributes
* text=auto eol=lf
*.png binary
*.jpg binary
*.pdf binary

Passo 5: CODEOWNERS

# .github/CODEOWNERS
*               @myorg/maintainers
/docs/          @myorg/docs-team
/infra/         @myorg/devops

Passo 6: template PR e issue

# .github/PULL_REQUEST_TEMPLATE.md
## Summary

## Test plan
- [ ]

## Screenshots / videos (if UI)

## Linked issues

Passo 7: hook pre-commit

npm install --save-dev husky lint-staged
npx husky init

# .husky/pre-commit
npx lint-staged

# package.json
"lint-staged": {
  "*.{js,ts}": ["eslint --fix", "prettier --write"]
}

Passo 8: configurazione CI

# .github/workflows/ci.yml
name: CI
on:
  push:
    branches: [main]
  pull_request:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm ci
      - run: npm run lint
      - run: npm test

Passo 9: scansione segreti

- uses: gitleaks/gitleaks-action@v2
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Passo 10: docs di contribuzione

Documentare branch naming, formato commit message e processo PR.

Passo 11: invitare il team

Aggiungere membri team con permessi appropriati.

Passo 12: prima PR

Creare una piccola PR per camminare attraverso il processo.

Manutenzione

  • Rivedere regole di protezione branch trimestralmente.
  • Aggiornare CODEOWNERS quando il team cambia.
  • Periodicamente prunare branch mergati.