Version Control and Developer Tooling Questions
The everyday toolchain of software work: version control with Git (branching, merging, rebasing, conflict resolution, using git bisect to find a regression), command-line and shell proficiency for day-to-day navigation, log inspection, and troubleshooting, IDE and editor workflows, build systems and package/dependency management (npm, Maven, pip, Gradle, CocoaPods, and embedded/cross-compilation toolchains), and the growing practice of AI-assisted coding: using, reviewing, and verifying AI-generated code and tests. Deliberately generic across languages and stacks; language- and domain-specific frameworks live in their own categories. This topic covers a developer's individual command of these tools, not: writing durable shell automation and glue scripts (Shell Scripting and Automation owns that), producing, versioning, and publishing build artifacts or container images (Build Automation and Artifact Management owns that), release cadence and change governance (Release Management and Change Control owns that), or diagnosing a live production incident end to end (Performance Troubleshooting and Incident Response and the Observability topics own that).
Design a small pre-commit and CI pipeline to run linting, unit tests, and static analysis on every local commit and on every push to a PR. Explain which checks run locally via pre-commit hooks, which run in CI only, how you avoid duplicating expensive checks, and how to keep developer experience fast.
Sample Answer
Direct answer
Run cheap, deterministic checks locally as pre-commit hooks, formatting and fast linting scoped only to changed files, so obvious mistakes never even get committed. Reserve expensive or whole-codebase checks (the full test suite, cross-file static analysis, security scanning) for CI, where they run once per push on shared infrastructure rather than blocking every local commit. Critically, CI must re-run the same fast checks the local hook did, not skip them, because local hooks are bypassable and CI is the only layer that's actually a real gate.
Structured elaboration
What runs locally, via pre-commit hooks (typically managed with a framework like pre-commit, or Husky for JavaScript projects), scoped to just the staged/changed files so they finish in seconds:
- Auto-fixable formatting (a formatter that rewrites the file and re-stages it)
- Fast linting on changed files only
- Lightweight secret-scanning (catching an obviously-committed API key before it ever leaves your machine)
- Optionally, a type-check scoped to changed files if your toolchain supports incremental checking
What runs only in CI:
- The full unit and integration test suite
- Static analysis that needs whole-codebase context (a full type-check across the project, not just changed files; broader static-analysis tooling)
- Anything requiring a full build/compile of the project
- Slower security or dependency-vulnerability scans
- A re-run of the same lint/format checks the local hook ran, this is the real enforcement point, since a hook can be skipped with
git commit --no-verifyor simply never installed by a contributor who didn't run the setup step
Avoiding duplicated expensive work: don't run the full test suite in a pre-commit hook, it's slow enough to make every commit painful. Don't skip re-checking lint/format in CI just because a local hook exists, that hook is only a courtesy, not a guarantee. Instead, make the CI-side re-check cheap by aggressively caching (dependency caches keyed on the lockfile hash, incremental test runners that only re-run what's affected by the diff), so paying for the same check twice costs almost nothing the second time.
Keeping developer experience fast: parallelize independent CI checks across jobs rather than running them serially. Scope local hooks tightly to staged files (via the pre-commit framework's file-filtering, or lint-staged in the JavaScript ecosystem) so they stay in the single-digit-seconds range. Prefer auto-fixing over just complaining, a formatter that rewrites and re-stages the file means a rejected commit usually just needs to be retried once, not manually fixed.
Worked example
Illustrative pre-commit config (exact tool versions should be pinned to the current release when you actually set this up, not copied verbatim from here):
repos:
- repo: https://github.com/psf/black
rev: <pinned-release>
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: <pinned-release>
hooks:
- id: ruff
args: [--fix]
Matching CI step that re-runs the same tools plus the full suite (illustrative):
- run: pre-commit run --all-files
- run: pytest
The local hook only ever sees staged files and finishes in a second or two; --all-files in CI checks everything that will actually be merged, catching anything a contributor's local hook missed or bypassed.
Trade-offs and pitfalls
Putting the full test suite locally feels thorough but trains developers to dread git commit, which quickly leads to habitual --no-verify use, defeating the hook's purpose entirely. The opposite mistake, putting nothing meaningful in CI because "the local hook already checked it," leaves the repo with no real enforcement at all, since local hooks are trivially skippable. The right split is genuinely asymmetric: local hooks exist for fast feedback and convenience, CI exists for actual enforcement, and the two should check largely the same things, just at very different cost budgets.
As a software engineer on a collaborative team, explain the difference between git merge and git rebase. When would you recommend using each approach for feature development and pull requests? Discuss effects on commit history, conflict resolution, code review ergonomics, and potential pitfalls such as force-push requirements and lost commits.
Sample Answer
Direct answer
git merge combines two branches by creating (or fast-forwarding to) a commit with two parents, preserving the exact history of what actually happened, including when the branches diverged. git rebase rewrites your branch's commits one by one on top of a new base, producing a linear history as if you had started your work from the target branch's latest commit. Use merge for shared or public branches, and to preserve the true chronological record; use rebase to clean up your OWN not-yet-shared feature branch before it is reviewed or merged.
Structured elaboration
- Effects on commit history: merge adds a merge commit (an extra node with two parents) and leaves the branch's original commits untouched, so the history literally shows when and how two lines of work joined. Rebase replaces the branch's original commits with new ones (same content, new hashes and a new parent), producing a straight line, at the cost of that history no longer reflecting when the work actually diverged.
- Conflict resolution: merge resolves all accumulated conflicts once, in a single merge step. Rebase can require resolving the same conflict repeatedly, once per replayed commit, if several commits touch the same lines. That is more tedious on a long-diverged branch, but each individual conflict is scoped to a smaller, more understandable diff.
- Code review ergonomics: rebasing a branch that is already under review invalidates the diff reviewers were looking at (new commit hashes), and a force-push can silently disconnect review comments from the old commits on some tools. Teams commonly agree "no rebasing mid-review" for this reason, but DO rebase (or otherwise clean up) a branch BEFORE opening the pull request, so what reviewers see is already a clean, logical set of commits.
- Pitfalls: rebase requires a force-push (
git push --force-with-lease, never a bare--force) to update a branch whose history you rewrote. That is dangerous on any branch someone else might also be working from, since it can strand or silently discard their local commits if they later force-push over yours. Never rebase a branch other people have already pulled and built work on top of, that is the one hard rule.
Worked example
This is a real, reproducible git session, run exactly as shown; your own commit hashes will differ every time you run it, since hashes are content- and timestamp-derived, but the shape of the history will match.
$ git init -q && git config user.email you@example.com && git config user.name You
$ echo line1 > file.txt && git add file.txt && git commit -qm "initial commit"
$ git checkout -qb feature/login
$ echo "login work 1" >> file.txt && git commit -qam "add login step 1"
$ echo "login work 2" >> file.txt && git commit -qam "add login step 2"
$ git checkout -q main
$ echo "main hotfix" >> readme.txt && git add readme.txt && git commit -qm "hotfix on main"
$ git log --all --oneline --graph
* f6a4e94 add login step 2
* 3f1b249 add login step 1
| * b203e9a hotfix on main
|/
* d00f83b initial commit
Merge:
$ git checkout -qb merge-demo main && git merge --no-edit feature/login
$ git log --oneline --graph
* 8d0f96b Merge branch 'feature/login' into merge-demo
|\
| * f6a4e94 add login step 2
| * 3f1b249 add login step 1
* | b203e9a hotfix on main
|/
* d00f83b initial commit
Rebase, from a fresh branch off feature/login:
$ git checkout -qb rebase-demo feature/login && git rebase main
$ git log --oneline --graph
* 80d6191 add login step 2
* 229c32c add login step 1
* b203e9a hotfix on main
* d00f83b initial commit
The merge history keeps both lines of development visible with a two-parent commit; the rebase history is a single straight line as though "login step 1" and "login step 2" were written after the hotfix.
Trade-offs & pitfalls
"Lost commits" after a rebase usually means a teammate had local commits based on the OLD (pre-rebase) branch tip, and either force-pushed over the new history or kept building on a branch tip that no longer exists remotely. --force-with-lease (which refuses to push if the remote moved since you last fetched) is a safeguard against silently clobbering that, not a substitute for the underlying rule: do not rebase a branch others have already pulled.
Describe how to redirect stdout and stderr to a file while also printing stdout to the terminal. Give the exact shell command(s) you would use in bash to: (1) capture both stdout and stderr to /tmp/run.log, and (2) simultaneously see stdout in the terminal. Explain why your approach works.
Sample Answer
Direct answer
Two building blocks solve this: 2>&1 merges stderr into stdout, and tee duplicates a stream to both the terminal and a file. Capture-only needs command > /tmp/run.log 2>&1. Capture-and-still-see-it-live needs command 2>&1 | tee /tmp/run.log.
Structured elaboration
# (1) capture both streams to the file, nothing shown on the terminal
your_command > /tmp/run.log 2>&1
# (2) capture both streams AND still see them live on the terminal
your_command 2>&1 | tee /tmp/run.log
Key points:
- File descriptor 1 (fd 1) is stdout, file descriptor 2 (fd 2) is stderr.
2>&1means "point fd 2 at wherever fd 1 currently points." - Order matters.
command > file.log 2>&1first redirects stdout to file.log, then makes stderr point at that same target, so both land in the file.command 2>&1 > file.logdoes the opposite: stderr is pointed at the terminal (wherever stdout currently was), and only then is stdout redirected to the file, so stderr stays on the terminal. This ordering mistake is the single most common bug with this idiom. teereads its own stdin and writes it to both stdout and the named file. That is why2>&1 | tee file.logworks: a pipe only ever forwards stdout by default, so stderr has to be merged into stdout with2>&1before it reaches the pipe if you wantteeto see it too.
Worked example
$ run_demo() { echo "stdout line"; echo "stderr line" >&2; }
$ run_demo 2>&1 | tee /tmp/run.log
stdout line
stderr line
$ cat /tmp/run.log
stdout line
stderr line
Both lines appear on the terminal and in the file, in the order the process wrote them. This was run exactly as shown.
Trade-offs & pitfalls
- Complexity is constant per line, this is OS-level file-descriptor plumbing, not a data scan, so cost tracks bytes written, not file size on disk.
- Ordering under a pipe: stdout is usually line-buffered when connected to a terminal, but becomes fully block-buffered once piped to
tee. If a process interleaves fast stdout and stderr writes, the captured order can differ slightly from an unpiped run. Force line buffering withstdbuf -oL your_commandwhen strict interleaving order matters. teeoverwrites the log file by default each run; usetee -a /tmp/run.logto append instead.- A plain redirect does not keep a process alive after you log out of SSH by itself, pair it with
nohupor a terminal multiplexer if the command needs to survive the session ending.
Dev secrets: propose an approach to secure secrets for local development that minimizes friction, and compare the realistic options for storing and distributing them. Discuss developer ergonomics, auditability, and offline development.
Sample Answer
Direct answer
There is no single right answer, only a trade-off across developer ergonomics, auditability, and offline development, and the right choice scales with team size. For a small team, an encrypted-in-repo file or a lightweight secrets-manager CLI beats a shared plaintext .env. For a team large enough that access needs to be revocable per person, a real secrets manager earns its setup cost, because auditability (knowing exactly who has fetched what, and being able to cut off one person's access without rotating the underlying secret) is a property nothing else on this list gives you.
Structured elaboration
| Approach | Developer ergonomics | Auditability | Offline development |
|---|---|---|---|
Plain .env, values shared manually (chat, a doc) | Fast to start, but propagating an updated value is manual and easy to forget | None: no record of who has which secret or when it was shared | Works fully offline once the file exists locally |
| Secrets manager (Vault, a cloud secrets manager, or a developer-focused tool like Doppler) with a CLI or agent | One-time login, secrets refresh automatically after that; needs the tool installed and reachable over the network at least once | Strong: every fetch is logged, access is per-identity and revocable without rotating the secret itself | Breaks, or falls back to a stale cache, the moment the network is unavailable, unless the tool explicitly ships an offline mode |
Encrypted-in-repo file (tools like sops or git-crypt) | Clone-and-decrypt is simple once keys are distributed; rotating a secret means committing a new encrypted blob | Git history shows who committed a change to the encrypted file, but not who actually decrypted and read the value locally | Fully offline once the repo is cloned and the decryption key is present |
| OS keychain (macOS Keychain, Windows Credential Manager) | Native, no extra file on disk, but strictly per machine, a new laptop means re-entering everything | Effectively none across a team; it is a single-machine, single-user store | Fully offline, it is entirely local |
Keep a documented, deliberate offline fallback (a clearly-labeled stub or a short-lived cached credential) for anyone stuck without network access. A workflow that hard-fails without connectivity gets worked around with a hand-copied plaintext file the first time someone is stuck at an airport, quietly recreating the exact risk the tool was meant to remove.
Worked example
A team of six starts with a shared .env.example and real values pasted into a team chat thread. When a contractor's engagement ends, the team realizes it would need to rotate every secret in that thread, because there is no way to know what the contractor still has a copy of; this is exactly the failure mode auditability buys back. They migrate to a lightweight secrets-manager CLI: each developer authenticates once, and a local wrapper script pulls current secrets into environment variables at the start of a dev session, fetched fresh each time, never written to disk in plaintext. Revoking the departed contractor's access afterward is a single action in the secrets manager, no rotation needed, because the underlying secret's value never left the manager's control in a form the contractor could independently retain.
Trade-offs and pitfalls
- A secrets-manager workflow is only as strong as its offline story; if the dev server hard-fails without network because it can't reach the vault, developers will improvise a local plaintext copy the moment connectivity is bad, quietly recreating the exact risk the tool was meant to remove.
- Encrypted-in-repo tools solve distribution but not real-time revocation: decrypting a secret onto a developer's laptop means it exists in plaintext there from that point on, so rotating the underlying value is still required if that laptop is compromised or that person leaves.
- Auditability is a property of the system, not of policy alone. Asking people not to share secrets over chat, without a technical alternative that is actually easier than chat, will not hold up under deadline pressure; the ergonomics and the security property have to point the same direction or the security property loses.
Describe the version control and branching strategies you used (git flow, trunk-based, feature branches). For a project where you were the feature owner, explain the exact workflow from branch creation to release, including PR review rules, CI gates, and merge policies.
Sample Answer
Direct answer
Three strategies cover most real teams: git flow's long-lived branches for slower, versioned releases; trunk-based development's very short-lived branches for continuous deployment; and plain feature branches off main, the common middle ground for most web and SaaS teams. As a feature owner, the workflow is branch, small commits with CI on every push, an early draft pull request, at least one required approval plus green checks, then merge and delete the branch.
Structured elaboration
- Git flow (long-lived
developplusreleaseandhotfixbranches alongsidefeature/*) fits teams shipping versioned, installable software on a slower cadence, for example a desktop application with numbered releases. The overhead of multiple long-lived branches buys a stable release line that can be patched independently of ongoing development. - Trunk-based development (very short-lived branches, often merged within a day or two, incomplete work hidden behind feature flags) fits teams doing continuous deployment. It minimizes merge conflicts by keeping divergence small, at the cost of needing feature flags for anything not ready to ship.
- Plain feature branches off
mainwith pull-request review is the most common real-world default for web and SaaS teams: no formaldeveloporreleasebranches, but a branch can live for the length of a feature, days to a couple of weeks. It avoids git flow's ceremony without demanding trunk-based development's discipline of flagging everything.
Worked example
This is an illustrative, composite account of a typical feature-owner workflow under the "feature branches" strategy, not a specific verifiable metric.
As the owner of a feature to add saved search filters, I branched feature/saved-search off main, aiming to keep it short-lived and merge within about a week. I opened the pull request as a draft on day one so teammates could see the direction early rather than review a finished wall of code. CI ran on every push, type checking, the unit test suite, and a lint gate, and the branch could not merge with a red check. Once the feature was functionally complete, I marked the PR ready for review and requested a teammate familiar with that part of the codebase as the required approver; our policy was at least one approval plus green CI before merge. Review turned up a real edge case, an empty filter set was not handled, and I pushed the fix as a new commit rather than rewriting history mid-review, so the reviewer's earlier comments stayed anchored to the right lines. Once approved, I squash-merged into main, collapsing many small "wip" commits into one clean commit with a summary message, and deleted the branch immediately after merge.
Trade-offs & pitfalls
- Letting a feature branch live too long, weeks instead of days, reintroduces exactly the merge-conflict pain trunk-based development exists to avoid, even under a plain feature-branch strategy. The shorter the branch lives, the smaller the eventual merge or rebase against
main. - Squash-merging trades a clean
mainhistory for losing the granular, commit-by-commit story of how the feature was actually built. Some teams prefer a regular merge commit, or rebase-and-merge, specifically to keep that history; there is no universally right answer, it is a team convention to agree on and enforce consistently. - Skipping a required CI gate "just this once" for a hotfix is how a broken build reaches
main. The gate has to apply uniformly or it stops meaning anything.
Unlock Full Question Bank
Get access to all Version Control and Developer Tooling interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.