What is a monorepo versus polyrepo, and what are the trade-offs?
CI/CD & GitOps · Advanced level
Answer
A monorepo stores multiple projects in one repository, which simplifies cross-project changes and shared tooling but requires selective builds and ownership controls. A polyrepo uses separate repositories, which improves isolation but can make cross-service coordination and dependency updates harder.
Technical explanation
Affected-build logic needs a dependency graph, not only file path matching, because shared libraries can impact many services.
Owners, path filters, and cache strategy become critical as repository size grows.
Git history is both collaboration state and audit evidence, so choose merge, rebase, revert, and reset based on whether history is shared.
Short-lived branches reduce merge conflicts and make CI feedback meaningful; long-lived branches increase drift and integration risk.
Tags, release branches, signed commits, and changelogs connect source history to released artifacts and operational traceability.
Prefer safe, reviewable operations on shared branches: revert bad changes, open PRs for backports, and avoid force-pushes unless the team explicitly coordinates them.
Hands-on example
1. Practice the Git operation for: What is a monorepo versus polyrepo, and what are the trade-offs in a throwaway repository with main, feature, release, and hotfix branches.
2. Add service folders such as services/api and services/worker plus a shared lib; use git diff --name-only origin/main...HEAD to map changed paths to affected builds.
3. Inspect the result with git log --oneline --graph --decorate --all and verify whether history was preserved, replayed, tagged, or safely undone.
4. Push through a pull request with required CI checks, run tests after conflict resolution or cherry-pick, and document why that operation was chosen.
5. For release scenarios, build from a signed tag, publish the artifact with the commit SHA and version, and confirm the release notes match the merged changes.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More CI/CD & GitOps interview questions
- What is CI/CD, and what is the difference between continuous delivery and continuous deployment?
- What are the goals of a CI pipeline beyond just running tests?
- What is Jenkins, and what is the difference between a controller and an agent?
- What is the difference between a freestyle job and a pipeline job in Jenkins?
- What is the difference between a declarative and a scripted Jenkins pipeline?
- What is a Jenkinsfile, and why keep your pipeline as code in the repo?
- Explain the structure of a declarative pipeline (agent, stages, steps, post).
- What is the post section used for, and what are its conditions (success, failure, always)?