Git line
Pull requests
Lamia keeps a draft, asks an editor to publish it, and the book changes only when the checks pass.
Stops explain each step. The film plays the whole ride.
- Asking
- Waiting
- Published
- Clash
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?
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.
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.
“The three methods leave the same history.”
What is a fork, a branch, and a clone?
A branch lives inside one repository. A fork is a separate repository. A clone is a copy on her computer.
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.
“A fork, a branch, and a clone are the same thing.”
What can a protected branch require?
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.
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.
“Trust people not to write in the book.”
How do you keep a review small?
One concern, the tests that prove it, and a title that says what changed. That is practice, not a rule of the site.
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.
“One huge request means fewer reviews.”
How does she update when the book gains pages?
Merge the book into the draft, or rebase the draft onto the book and push with a lease.
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.
“Push with a blind force and hope.”
Cheat-sheet
Commands you will actually type.
git switch -c feat/xStart a draft branch from the current pages.
git push -u origin feat/xSend 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-branchFold it into one commit. Deleting the branch is this flag, not the default.
git fetch origin && git rebase origin/main && git push --force-with-leaseReplay onto the book, then push only if nobody else moved the draft.