Module 3. Practice: from requirements to automated tests · Lesson 25 of 41 · 15 min
Git for testers: branches, pull requests, reviews and git hooks
The Git minimum a QA engineer needs: clone, branch, commit tests, open a PR, review changes; pre-commit and pre-push hooks.
Why QA needs Git
Automated tests, test data, Postman collections and even Markdown test cases live in the repository. A tester who knows Git can add a test, see what changed in a release and verify a fix on a specific branch without waiting for anyone.
Everyday commands
| Command | What it does |
|---|---|
| git clone URL | Download the repository |
| git switch -c feature/promo-tests | Create a branch and switch to it |
| git status | What's changed |
| git add tests/promo.spec.ts | Stage a file for commit |
| git commit -m "test: promo code SALE10" | Record the changes |
| git push -u origin feature/promo-tests | Push the branch |
| git pull --rebase | Pull in fresh changes |
| git log --oneline -10 | The latest commits |
| git diff main...feature/x | What changed on the branch compared to main |
A pull request through QA's eyes
What to look at in a developer's PR, even without deep knowledge of the code:
- Which files changed — a hint at which modules are affected and what to add to regression.
- Are there tests for the new behavior?
- Database migrations — need separate data checks (see SQL for testers).
- Config and feature flag changes — what's on by default?
- The PR description links to the ticket and its acceptance criteria.
To check a fix before merging: git fetch, git switch branch-name, run it locally or on the preview environment many CI setups (Vercel, Netlify) create for every PR.
Git hooks
A hook is a script Git runs automatically on a given event. Two are the most useful for quality:
- pre-commit — before a commit: linter, formatting, blocking a committed .only in tests.
- pre-push — before pushing: quick unit and API tests.
In JS projects they're usually set up with husky and lint-staged:
{
"scripts": { "prepare": "husky" },
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"tests/**/*.spec.ts": ["node scripts/no-test-only.js"]
}
}
# .husky/pre-push
npm run test:unit && npx playwright test --project=api
Hooks are a local safety net, not a replacement for CI: anyone can skip them with --no-verify. The final check belongs to the pipeline — see CI/CD for automated tests.
Commit conventions
Messages like test: ..., fix: ..., feat: ... (Conventional Commits) make release notes and searching easier. Reference the ticket: test(US-214): promo code boundaries.
Key takeaways
- Nine Git commands cover a QA engineer's daily work with automated tests.
- In a PR, a tester looks at changed modules, migrations and feature flags.
- pre-commit and pre-push hooks catch problems before CI but don't replace it.
Check yourself
1. Which command shows what changed on a branch compared to main?
2. What belongs in a pre-commit hook?
3. Do git hooks guarantee untested code never reaches main?