Stop by Stop

Git line

Pull requests

Lamia keeps a draft, asks an editor to publish it, and the book changes only when the checks pass.

Words to know

Stops explain each step. The film plays the whole ride.

Explain it
Route
LamiaThe writerHer draftHer copyThe deskThe noteYusufThe editorThe bookThe pages
  • Asking
  • Waiting
  • Published
  • Clash
Stop 1 of 7

She copies the book

Lamia copies the book into her own draft so the published pages stay as they are.

Next stop: She sends the draft

All stops

The everyday version

A shared book. Her draft is a copy, the desk is the cover note, and the book changes only when the checks pass and the editor agrees.

  • Lamiais the Author

    The writer who keeps a draft and asks for it to be published.

  • Her draftis the Head branch

    A copy of the book. The published pages stay put while she writes.

  • The deskis the Pull request

    The cover note that asks the editor to put this draft into the book.

  • Yusufis the Reviewer

    The editor who approves, comments, or asks for a change.

  • The bookis the Base branch

    The published pages. The draft joins them only after the checks pass.

Interview questions

Say the short answer first. Go deeper only if they ask.

What is the difference between a merge commit, squash, and rebase and merge?
Short answer

A merge commit keeps the commits and adds a merge point. Squash makes one commit. Rebase and merge replays each commit with a new identity and no merge commit.

If they dig deeper

GitHub can allow any mix of the three, and the person merging chooses when more than one is on. A merge commit uses no fast-forward, so the branch commits stay and a merge commit joins them. Squash folds every commit on the pull request into one new commit and fast-forwards. Rebase and merge adds each commit onto the base with no merge commit, and GitHub always writes a new committer and new commit identities. A local rebase does not always change the committer. A merge queue removes the choice.

Answer that loses points

“The three methods leave the same history.”

What is a fork, a branch, and a clone?
Short answer

A branch lives inside one repository. A fork is a separate repository. A clone is a copy on her computer.

If they dig deeper

People without write access use a fork. A team with write access uses a branch in the same repository. With the exception of GITHUB_TOKEN, secrets are not passed to a workflow that a fork pull request triggers, and that token is read-only on pull_request from a fork. pull_request_target runs from the base repository and does receive secrets, so checking out the fork’s code there is the risk.

Answer that loses points

“A fork, a branch, and a clone are the same thing.”

What can a protected branch require?
Short answer

A set number of approvals, a code owner, and checks that are successful, skipped, or neutral. Requiring a pull request does not by itself require an approval.

If they dig deeper

Requiring a pull request before merging does not by itself require an approval. The required count is a setting, from zero to six in the API, or a review from a code owner. Request changes from an admin blocks until that person approves or someone with write or admin dismisses it. Dismissing stale approvals when the diff changes is optional, not the default. Requiring approval of the latest reviewable push is a separate option and is off unless set. Requiring the branch to be up to date is an extra checkbox. Admins can be included or exempt.

Answer that loses points

“Trust people not to write in the book.”

How do you keep a review small?
Short answer

One concern, the tests that prove it, and a title that says what changed. That is practice, not a rule of the site.

If they dig deeper

Draft pull requests are for early feedback. Stacked pull requests are a convention for a large change. Mixing a rename with a behaviour change makes the diff hard to read. None of this is required by GitHub.

Answer that loses points

“One huge request means fewer reviews.”

How does she update when the book gains pages?
Short answer

Merge the book into the draft, or rebase the draft onto the book and push with a lease.

If they dig deeper

Merging the base into the head adds a merge commit on the draft and is the safer update when other people share that draft. Rebase rewrites the draft’s commits. The next push then needs --force-with-lease, which refuses if the remote moved since the last fetch. It is not safe against every race. A blind --force can throw away someone else’s push.

Answer that loses points

“Push with a blind force and hope.”

Cheat-sheet

Commands you will actually type.

git switch -c feat/x

Start a draft branch from the current pages.

git push -u origin feat/x

Send the draft and remember its upstream.

gh pr create --title "New page" --body "Adds the ending."

Open the request with a title and a note.

gh pr merge --squash --delete-branch

Fold it into one commit. Deleting the branch is this flag, not the default.

git fetch origin && git rebase origin/main && git push --force-with-lease

Replay onto the book, then push only if nobody else moved the draft.

Sources