Level:
No questions match — try other words or turn a level back on.
1
People call Git a "distributed" version control system. What does that mean in practice?
Every developer has a full copy of the repository: the whole history, branches and commits. Committing, log, diff and creating branches all work locally with no server; the server is only needed for exchanging changes.
2
What is the difference between the working directory, the staging area and the repository?
The working directory is the files on disk that you are editing. The staging area (index) is where you gather what goes into the next commit. The repository is the commit history stored inside .git.
3
Why does saving a change in Git take `git add` first and then `git commit`? Isn't one command enough?
The two steps let you choose exactly what goes into a commit. With add you gather the changes you want, and commit records them in history as one coherent step.
4
What does a good commit message look like? What is wrong with writing "fix" or "update"?
A good message says what changed and why: a short title (up to 50-70 characters), and if needed, after a blank line, an explanation. Six months later "fix" tells you nothing.
5
What is the difference between `git fetch` and `git pull`?
git fetch downloads new commits from the remote but does not touch your branch. git pull does a fetch and then immediately merges (or rebases) into the current branch.
6
What is a branch in Git, really? Why is creating a new branch so fast?
A branch is a named pointer to a single commit. It is a tiny file holding just the commit hash, so creating a branch copies no files and happens instantly.
7
What do `git diff` and `git diff --staged` show?
Plain git diff shows changes that have not been added to staging yet. git diff --staged (or --cached) shows the changes that were git added, that is, the ones that will go into the next commit.
8
What is the `.gitignore` file for, and what usually goes into it in a Java project?
.gitignore lists files Git should not track: build output, IDE settings, local secrets, logs. That way they do not end up in a commit by accident.
9
You ran `git push` and got "rejected, non-fast-forward". What does it mean and what do you do?
The branch on the server has commits you do not have: someone pushed before you. First you bring them in (git pull or git pull --rebase), resolve any conflict, and then push again.
10
What is HEAD in Git?
HEAD is a special pointer that shows which commit you are on right now. Usually it points to a branch (for example main), and the branch in turn points to the latest commit.
11
Which variants of `git log` do you use to view commit history comfortably in the terminal?
In daily work, git log --oneline --graph --decorate is what I need most: each commit on one line, the branch lines, and where each branch points. For filtering you add --author, --since and a file path.
12
What is a merge conflict and when does it happen?
When two branches have changed the same place in the same file in different ways, Git cannot decide which version is right and leaves the decision to you. That is a conflict.
13
When and why did `git switch` and `git restore` appear instead of `git checkout`?
In Git 2.23 the two different jobs of checkout were separated: switch changes branches, restore restores files. Because one command did two things, it was easy to make mistakes.
14
What is a remote? Where does `origin` come from?
A remote is a reference (a URL) to a repository somewhere else, given a short name. origin is the default name Git sets automatically when you run git clone, and it has no other special meaning.
15
In what situation does `git stash` help?
When your work is half done and you need to switch to another branch quickly, git stash temporarily sets aside uncommitted changes. Later you bring them back with git stash pop.
16
How do you discard uncommitted changes in a file and go back to the state of the last commit?
git restore <file> returns the change on disk to the state of the last commit (more precisely, of staging). If the file was already git added, first run git restore --staged, then a plain restore.
17
You made a mistake in the last commit message, or forgot to add a file. How do you fix it?
git commit --amend replaces the last commit with a new one: you can change the message or add the new files from staging. It is safe to use only if the commit has not been pushed yet.
18
What is a tag in Git, and how does it differ from a branch?
A tag is also a pointer to a commit, but it stays fixed in one place: it does not move when you make new commits. It is usually used to mark release versions, for example v1.4.0.
19
What is a pull request (a merge request in GitLab), and why do you not push straight to `main`?
A pull request is a proposal to merge the changes on your branch into the main branch. Before the code goes in, colleagues review it, CI runs the tests, and the discussion stays in one place.
20
What is the difference between a fork on GitHub and `git clone`?
clone copies a repository to your computer. A fork creates a copy of the repository on the server itself, under your account. A fork is not a Git command, it is a GitHub/GitLab feature.
21
What is the difference between a fast-forward merge and a merge that creates a merge commit?
If main has not moved forward since you created your branch, Git simply moves the main pointer to your last commit, and that is a fast-forward. If both sides have new commits, a new merge commit with two parents is created.
22
How do `git reset --soft`, `--mixed` and `--hard` differ?
All three move the branch back to the given commit. --soft leaves the changes in staging, --mixed (the default) leaves them on disk but takes them out of staging, and --hard removes them completely.
23
A commit has already been pushed to `main` and then turned out to be wrong. Do you remove it with `reset` or with `revert`?
On a shared branch you use git revert: it adds a new commit that applies the opposite of the bad commit and does not rewrite history. reset + force push breaks other people's history.
24
What does the message "You are in 'detached HEAD' state" mean, and will the commits you make in this state be lost?
HEAD points directly at a commit, not at a branch. You can commit in this state, but no branch points to those commits, so if you switch to another branch they are left "dangling". To keep them, run git switch -c new-branch.
25
You accidentally committed the database password and pushed to GitHub. What do you do first?
First you change the password (rotate it): assume it is already exposed. Then you take it out of the code and move it to the environment or a secret manager, and if needed, clean it out of the history too.
26
How does `git pull --rebase` differ from a plain `git pull`, and why do many people prefer it?
A plain pull merges the server's changes and often creates an unneeded "Merge branch 'main' of ..." commit. --rebase puts your local commits back on top of the server's, and the history stays a straight line.
27
You added `application-local.yml` to `.gitignore`, but Git still shows changes to it. Why, and how do you fix it?
The file was committed earlier, so Git is already tracking it, and .gitignore works only on untracked files. You need to remove the file from the index with git rm --cached and commit that change.
28
When developers on Windows and macOS work in one repository, whole files show up as "changed" although nothing actually changed. What is the cause?
Line endings: Windows uses CRLF (\r\n), while Linux/macOS use LF (\n). Git counts every line as changed. The fix is to set a rule at the repository level with .gitattributes.
29
How do you resolve the conflict below? How do you find out what changed on each side?
The HEAD part is your current branch, and the bottom part is the branch being merged in. Both changes are needed here: one raised the timeout and the other added retry, so you write them combined.
30
How do you delete a finished branch locally and on the server? What is the difference between `git branch -d` and `-D`?
-d deletes the branch only if it is fully merged, and otherwise warns you. -D deletes it without asking anything. The branch on the server is deleted with git push origin --delete <name>.
31
When do you choose merge, and when rebase?
Rebase to update my own branch that nobody else has used yet, and to keep the history clean. Merge for combining shared branches, and wherever rewriting history is risky. The main rule: do not rebase commits that others have pulled.
32
Before a PR, how do you clean up commits on the branch like "wip", "fix typo" and "review fixes"?
With git rebase -i (interactive rebase): you squash/fixup the unneeded commits into the main ones, fix messages with reword, and reorder. This is done only on a personal branch.
33
A bug in prod was fixed on `main`, but it is needed on the `release/2.3` branch too. How do you do that without merging all of `main`?
With git cherry-pick <hash> you copy exactly that fix commit onto the release branch. Git takes the commit's diff and applies it as a new commit on the current branch.
34
You ran `git reset --hard` and "lost" commits you needed. How do you get them back?
git reflog keeps a local record of where HEAD and the branches have been. You find the commit hash from before the reset in it, then get it back with git reset --hard <hash> or with a new branch.
35
What is the difference between `git push --force` and `git push --force-with-lease`?
--force replaces the branch on the server with your local state regardless of anything. --force-with-lease writes only if the branch on the server is in the state you last saw, and refuses if someone pushed in the meantime.
36
Compare Git Flow, GitHub Flow and trunk-based development. Which would you choose for a small backend team?
Git Flow / GitHub Flow / Trunk-based — Main branches: main + develop / main / main; Feature branch lifetime: days to weeks / 1-3 days / hours, sometimes no branch; Release: through a release branch / every merge from main / from main, often; Fits: boxed products, mobile apps, supporting several versions / web services…
37
When you review a colleague's PR, what do you look at?
First why the change was made and whether the approach is right, then bugs, security, transactions and concurrency, and whether there are tests. I leave formatting and style to the linter, and I write comments respectfully and specifically.
38
How do you manage release versions with Git tags, and how does semantic versioning relate to that?
Every release is marked with an annotated tag, for example v2.4.1. By SemVer, MAJOR is a backward-incompatible change, MINOR is a new feature, and PATCH is only a fix. CI sees the tag and builds the artifact and image with that version.
39
The tests passed a month ago and fail now, and there are 300 commits in between. How do you quickly find the commit that broke them?
With git bisect: you mark one "good" and one "bad" commit, and Git does a binary search through the commits between them. For 300 commits, about 8-9 steps are enough, and with a test script the process can be fully automated.
40
On GitHub there are three ways to merge a PR: merge commit, squash and merge, and rebase and merge. How do they differ in the history?
A merge commit keeps all the commits from the branch and the merge commit that joins them. Squash turns the whole PR into a single commit on main. Rebase and merge puts each commit on top of main separately, but without a merge commit.
41
How does Git store a commit internally? How are blob, tree and commit objects linked together?
Git is a content-addressable store: each object is stored under the hash of its contents. A blob is file contents, a tree is a directory (names and references to blobs/trees), and a commit is the root tree, parent commits, the author and a message. The chain of hashes makes history immutable.
42
What are Git hooks? Why is enforcing commit rules in a team with client-side hooks alone not enough?
A hook is a script that Git runs automatically at certain moments (commit, push, merge). Client-side hooks live inside .git/hooks, are not distributed with a clone, and can be bypassed with --no-verify. So the main check has to be in CI and on the server side.
43
A colleague rebased and force pushed a shared branch you are working on. Now when you `git pull`, every commit appears twice. How do you recover?
You are standing on the old commits, while the server has their rewritten copies. You need to move only your own new commits onto the new base: git rebase --onto, or git pull --rebase (which tries to work out the fork-point itself).
44
On a long-lived branch, every time you update from `main` you resolve the same conflicts again. How does `git rerere` help?
rerere (reuse recorded resolution) remembers how you resolved a conflict. If exactly that conflict comes up again, Git applies the earlier resolution automatically. It is especially useful with repeated rebases and trial merges.
45
A feature branch was merged into `main`, then the merge commit was reverted because of a problem. After fixing the bug, when you merge the branch again, the old changes do not come. Why?
The revert removed the code, but in the history the branch's commits are already counted as part of main. On a second merge Git takes only the new commits. You first need to revert the revert commit, then merge the new fixes.
46
Big binary files (test dumps, images, model files) were added to the repository and a clone has grown to 3 GB. Why is this a problem, and how do you fix it?
Git stores every version in full, and every clone downloads the whole history, while binaries delta-compress badly. For new files you use Git LFS, and to clean the old history you need git filter-repo and a force push.
47
Several services need to share code (proto files or configuration, for example). How do you choose between a Git submodule and a subtree?
A submodule is a reference to an exact commit of another repository: the code stays separate and the version is precise, but it needs extra steps in clone, update and CI. A subtree copies the other repository's contents into your own history: using it is simple, but sending changes back is awkward.
48
A monorepo has 40 services, and every PR builds the whole project, so CI takes 50 minutes. How do you speed it up at the Git and CI level?
The main idea is to build and test only what changed: find the affected modules with git diff and run them together with their dependents. On top of that: shallow/partial clone, sparse-checkout and a build cache.
49
What are Conventional Commits, and how can they be used to automate the version and the CHANGELOG?
It is a convention for commit messages: prefixes such as feat:, fix:, feat!: or BREAKING CHANGE:. Tools (semantic-release, release-please) use these prefixes to compute the next SemVer version, write the CHANGELOG and create the tag.
50
How do you protect the `main` branch? How do branch protection, required checks and CODEOWNERS work together?
Branch protection closes direct pushes and force pushes and requires a PR, an approval and green CI for merging. CODEOWNERS defines who must review which folder. Together they move the rule from people's memory to the server.
51
Git names commits with SHA-1. After the SHAttered attack, is this a security problem, and where does the move to SHA-256 stand?
Since Git 2.13 it uses collision-detecting SHA-1 (SHA-1DC), which rejects SHAttered-style files. SHA-256 repos are created with --object-format=sha256, but support in hosting services and tools is still incomplete.
52
How do you check that every commit in a PR compiles and passes tests on its own?
git rebase -i --exec "./mvnw -q test" origin/main runs the command after every commit and stops where it fails. I fix that commit, then git commit --amend and git rebase --continue.
53
A conflict came up in the middle of a rebase. What do you do now, and how do you safely go back?
I resolve the conflict, git add, and continue with git rebase --continue. I --skip a commit that is no longer needed, and if everything gets tangled, git rebase --abort returns the branch to its state before the rebase.
54
What is the difference between `git log main..feature` and `git log main...feature`? And what do two and three dots mean in `git diff`?
In log, A..B means commits that are in B and not in A, and A...B means commits that are on only one side. In diff, A..B simply compares A and B, while A...B shows the changes from the merge base to B, that is, only the changes on B's side.
55
Are `git merge -s ours` and `git merge -X ours` the same thing? Which one do you use and when?
No. -s ours is a separate strategy: it discards all the changes from the other branch and only writes a merge commit. -X ours is an option of the ordinary ort merge: all changes are taken, and only in the hunks that conflict is your side chosen.
56
You moved a class to another package and changed it a bit. How does Git detect a rename, and why does `git log` stop showing the old history?
Git does not store a rename separately: a path disappears from the tree and another appears, and then it guesses "this is a rename" by content similarity (50% by default). git log -- new/path looks only at that path, and for the old history you need --follow.
57
`git status` says "Your branch is ahead of 'origin/main' by 2 commits" or "have diverged". What does it mean, and how is upstream set up?
The local branch is compared with its upstream (usually origin/<name>) as of the last fetch: ahead means unpushed commits, behind means server commits you do not have, and diverged means both. Upstream is set with git push -u or --set-upstream-to.
58
You cherry-picked a hotfix onto `main`, and then the whole release branch was merged. What happens in the history?
The same change shows up twice with two different hashes. Most of the time the merge goes through without trouble, because the diff is identical, but if those lines were changed in between, an unexpected conflict or even the return of old code is possible.
59
A colleague rebased a PR after review and force pushed. How do you see what changed without rereading the whole diff?
git range-diff compares the old and new commit series pair by pair: which commit changed, which was added or dropped. I take the old tip from the origin/... reflog; GitHub and GitLab also have "compare with the previous version".
60
Cloning a big repo in CI takes 4 minutes. How do shallow and partial clones help here?
A shallow clone (--depth 1) cuts the history: only the latest commits come. A partial clone (--filter=blob:none) gets the whole history but downloads file contents only when needed. For CI the first is often enough.
61
CI fails with `./mvnw: Permission denied`, while everything works locally. How does Git store file permissions, and how do you fix this?
Git stores only one permission bit: a file is executable (100755) or regular (100644). A mvnw committed from Windows or with core.fileMode=false stays 644. You need to run git update-index --chmod=+x mvnw and commit.
62
On macOS you renamed `orderService.java` to `OrderService.java`. Git does not see the change, and CI on Linux cannot compile. What is going on?
The macOS and Windows file systems are not case sensitive by default, and Git works there with core.ignorecase=true, so it does not notice a change of case alone. The old name stays in the repo, and on Linux javac fails because the public class name does not match the file name.
63
What does `git stash` actually save, and in which cases do your changes not end up in the stash?
A stash is made of special commits: one for the index state, one for the working tree, and a third one for untracked files if requested. By default untracked and ignored files do not go into the stash, and you need -u or -a for them.
64
You need to restore a single file to its state on another branch or in an old commit, without touching the other files. How do you do it?
git restore --source=<commit> -- <file> brings the file to its state in that commit, by default only in the working tree; with --staged --worktree the index is updated too. If you only need to look at it, use git show <commit>:<path>.
65
How does a three-way merge work, and why does the merge base matter?
Git compares the tips of two branches with their closest common parent commit (the merge base). A place changed on only one side is taken automatically, and if both sides changed the same place differently, it is a conflict.
66
A commit has two kinds of information: author and committer. When do they differ, and why does the commit date change after a rebase?
The author is the person and time that wrote the change, and the committer is the person and time that created the commit in its current form. Rebase, cherry-pick and amend recreate the commit: the author is kept, and the committer and its date are updated.
67
How do you find out when and why a strange condition in a method was added?
git blame shows the last commit that changed a line, but formatting or moving can mislead it. So I follow a function's history with blame -w -C, git log -S/-G (pickaxe) and git log -L.
68
In a big refactoring PR, code was moved from one place to another and reformatted. Which Git options do you use to make the diff easy to read?
--color-moved shows moved blocks in a separate color, -w hides whitespace changes, and --word-diff gives the difference inside a line word by word. First I look at the overall picture with --stat.
69
You need to verify a hotfix for prod, but you have a half-finished feature. How does `git worktree` help here?
git worktree opens several working folders from one repo, each with a different branch. You make the hotfix in a separate folder, without stashing and without re-indexing the IDE.
70
At which levels are `git config` settings stored, and how do you automatically separate different emails and SSH keys for work and personal projects?
The main levels are system (/etc/gitconfig), global (~/.gitconfig) and local (.git/config); the lower level wins. For the work folder I attach a separate file with includeIf "gitdir:~/work/" and set user.email and core.sshCommand in it.
71
Moving from Spring Boot 2 to 3 needs a mechanical change that touches all the code, such as `javax.*` → `jakarta.*`. How do you handle this on the Git side without breaking the team's open PRs?
I turn the mechanical part into a recipe that can be rerun (OpenRewrite) and land it as a separate "mechanical only" commit in an agreed window. Owners of open PRs run that recipe on their own branch, then merge the mechanical commit with -s ours, so there are almost no conflicts.
72
How do you use feature flags so that you do not have to keep a three-week feature on a separate branch?
The code lands on main in small pieces, but because the flag is off, users do not see it. That keeps merge conflicts small, and release is separated from deploy: turning the flag on is a separate decision.
73
Versions 3.2 and 3.3 are running in prod, while `main` has moved on to 3.4. How do you deliver a security fix to all versions?
I make the fix on main where possible, then backport it to each release branch with cherry-pick -x, with separate CI and a tag for each. Or the reverse: make it on the oldest branch and merge upward. What matters is that the team has one direction.
74
A new release caused a problem in prod. Do you `git revert` and redeploy, redeploy the old version, or roll forward? Which one, and when?
The first step is almost always to redeploy the previous, tested artifact. That is fast and does not depend on Git. Then on main I either revert the bad commit or move forward with a fix. If the migration is not backward compatible, only roll forward is left.
75
PRs in your team sit for 3-4 days waiting for review. How do you speed up the code review process without lowering quality?
The main lever is PR size: a PR of around 200-400 lines gets reviewed fast and well. On top of that I make review part of the daily rhythm, hand the mechanical checks (format, lint, tests) to CI, and name the reviewers explicitly.
76
You want to release an internal library as open source on GitHub. Do you publish it with the current Git history, and what do you check first?
The history may contain old secrets, internal host names, customer data and employees' personal emails. I check the whole history with secret scanners, and if it is not clean, I open a new repo with a single initial commit with no history, and the internal history stays in the private repo.
77
The repo has grown: `git status` takes 6 seconds and a clone takes 15 minutes. How do you diagnose it, and what do you tune?
First I measure what is slow: the file count (working tree), the history size, or big binaries. Then I pick the right tool: fsmonitor and the untracked cache, sparse-checkout, partial clone, and git maintenance with a commit-graph and multi-pack-index.
78
Renovate or Dependabot opens 30 dependency PRs every week, and the team ignores them. How do you organize this work?
I group the PRs (test libraries in one PR, for example), auto-merge patch and minor updates when CI is green, and review majors separately with an owner. A schedule and a limit on simultaneous PRs reduce the noise.
79
When you send a big change as several dependent PRs (stacked PRs), how do you work with Git?
Each PR is based on the branch of the previous one: feat-1 ← feat-2 ← feat-3. If a lower PR changes, the ones above must be rebased, and git rebase --update-refs does that in one command. Merging goes from the bottom up.
80
Every PR conflicts in `pom.xml`, `application.yml` or a shared `ErrorCode` enum. How do you reduce this at the repo and code structure level?
Conflicts often come from "hot" files that everyone is forced to write to. I split them up: versions go to a BOM, configuration to separate files per module, and central lists move closer to the module. For the rest, ordering rules help.
81
For a company with 40 Java microservices, how do you decide between a monorepo and a polyrepo?
This is not a Git decision, it is an organizational one: a monorepo gives atomic changes and a single version policy, but requires a big investment in the build system and tooling. A polyrepo gives teams independence, but cross-service changes and dependency versions become scattered.
82
The company wants to move 300 repos from a self-hosted GitLab to GitHub. Besides the Git history, what moves, what does not, and how do you plan it?
The Git part is easy: branches and tags move completely with a mirror clone. The hard part is the platform: MRs and comments, CI pipelines, permissions, webhooks, branch protection, LFS, package registries and secrets. I start with an inventory, then move with a pilot and waves.
83
Changing the event format in a shared `common-events` library affects 12 repos. How do you deliver this change?
A single atomic change is not possible in a polyrepo, so I do expand/contract: first a version that supports the old and new formats together, then migrate consumers step by step, and remove the old format at the end. I automate the coordination.
84
Two developers used the same Flyway version on parallel branches. How do you prevent such collisions at the system level?
Sequential numeric versions will inevitably collide in parallel work. The solution is to use a timestamp as the version, run flyway validate in CI together with main, and use a merge queue to guarantee migrations land on main one after another.
85
Why is a merge queue needed, and what problem does it solve?
Two PRs can each be green on their own but break main together, because each was tested without the other. A merge queue puts PRs in a line and tests each one merged with the ones ahead of it, and only then adds it to main.
86
For supply chain trust in the origin of code, should signing of commits and tags be rolled out across the organization?
A signature says "this very key owner created this commit", while user.email can be forged at will. I make signing of release tags mandatory, and roll out commit signing so that it is checked on the server side, while keeping key management simple.
87
You have to rewrite the history of a repo used by the whole company (because of a secret or big files). How do you plan it?
I plan it like a deploy: an announcement in advance, a code freeze window, new history with git filter-repo, verification of the result, a force push, everyone cloning again, and blocking pushes from old clones. If it is a secret, rotate it first.
88
Where should policies (commit format, file size, protected paths) be enforced: in a client hook, a server-side pre-receive hook, or in CI?
A client hook is only for quick feedback and is not reliable. A pre-receive hook: the server rejects the push and it cannot be bypassed, but it slows down every push and is hard to manage. CI and branch protection are the best place for most rules. I deliberately split rules across these three layers.
89
How do you build a branch strategy for supporting 3 LTS versions of a product installed at customers in parallel?
A long-lived release/X.Y branch for each LTS, with fixes starting from the oldest version that needs them and merged upward, or going down from main with an automated backport. The main cost is not in Git but in keeping CI, tests and dependency updates alive for every version.
90
How do you move 15 service repos into a single monorepo without losing history?
I move each repo's history into its own folder with git filter-repo --to-subdirectory-filter, then merge it into the monorepo with --allow-unrelated-histories. The Git part is easy; the main work is the plan for moving the build, CI, ownership and open PRs.
91
In a large organization the code review load has landed on a few seniors. How do you fix this at the system level?
First I collect data: who does how many reviews, and where the waiting is long. Then I spread the load by widening ownership (a team, not a person, in CODEOWNERS), a review rotation, requirements that differ by risk, and automating the mechanical checks.
92
An auditor asks: "who wrote each change in prod, who approved it, and when did it go out?" How do you build that traceability from Git and CI?
Every deploy is tied to an exact commit SHA, every commit gets into main only through an approved PR, and the PR is linked to a ticket. That gives the chain: ticket → PR (author, reviewers) → commit → build (artifact digest) → deploy (who, when, which environment).
93
How does the release train model differ from continuous deployment in its effect on branch strategy?
In a release train, on set days a release branch is cut from main, stabilized and shipped on a schedule, so there are branches and backports. In continuous deployment, every green commit of main goes to prod, there is almost no release branch, and risk is managed with feature flags and progressive rollout.
94
For internal libraries in a monorepo, how do you choose between a "single version" policy and independent versioning?
Under a single-version policy, every service uses the library as it is on main: there is no "dependency hell", but whoever introduces a breaking change has to fix every service that uses the library. Independent versioning gives teams freedom, but loses the monorepo's main advantage.
95
Should generated code (an OpenAPI client, protobuf, jOOQ classes) be stored in Git?
Usually not: the source (spec, .proto, migrations) is in Git and the code is generated at build time. But if generation is expensive, unreliable or depends on an external resource, or if seeing how the output changes in review matters, committing it pays off, with a "is it up to date" check in CI.
96
Someone force pushed to `main` from an old local copy and wiped out the last day's 30 merges. How do you recover, and what do you do so it does not happen again?
The commits are not lost: the old tip exists in someone's clone, on CI runners, in the platform's push logs, or in the server reflog. I find that SHA and move main back to it, and then forbid force push on protected branches.
97
In GitOps, do you keep application code and deploy configuration in one repo or separately?
Usually separately: the application repo builds the image, and the config repo (Helm/Kustomize manifests) says which image digest runs in each environment. That keeps the deploy history clean, permissions separated, and lets one code commit go out to several environments at different times.
98
In an organization with hundreds of developers and outside contractors, how do you structure repo access, and what do you do when an employee leaves?
Permissions go not to people but to teams synced from SSO, and the default is the minimum (a contractor gets only the repos they need). If an employee leaves, one deletion in the IdP closes the account, SSH keys and tokens. But I also account for the fact that code that has been cloned cannot be taken back.
99
The company forked an open source project (Keycloak, say) and made its own changes. How do you stay in sync with upstream?
I keep the fork's changes minimal and isolated: through a plugin/extension if possible, otherwise as a clear set of patches rebased on top of every upstream release tag. A regular update cycle and sending changes back upstream are the main rules.
100
How do you measure a team's delivery speed (lead time) from Git and PR data, and how should these numbers not be used?
Lead time is the time from commit to prod. I measure it split into stages by the timestamps of the first commit, PR opened, first review, merge and deploy. That shows where things get stuck. But if it is used to compare or evaluate people, it breaks immediately.
Sign up — studied questions get marked and your progress is saved.