Git & GitHub Course
Git & GitHub
/
Beginner

Draft Pull Requests

Definition

A special state for a Pull Request that clearly indicates the code is a work in progress, preventing it from being accidentally merged and suppressing review notifications.

Explain Like I'm New

Sometimes you want to show your code to a coworker to ask a question, but the code is half-broken and not ready to be officially reviewed. You open it as a 'Draft'. The merge button is greyed out and physically locked so nobody can accidentally deploy your broken code.

Real World Example

Opening a Draft PR at the start of the week just to use it as a checklist, and clicking 'Ready for Review' on Friday when you finish the feature.

Common Use Cases

  • •Early feedback
  • •Preventing accidental merges of unfinished code

Terminal Output

bash / terminal
/* How to create a Draft PR: 1. Push your branch to GitHub. 2. Click 'Compare & pull request'. 3. Instead of clicking the big green 'Create pull request' button, click the little dropdown arrow next to it. 4. Select 'Create draft pull request'. */

Interview Questions

basic

  • Can a Draft PR be merged?

intermediate

  • Does opening a Draft PR trigger notifications to code owners?

Flash Cards

Question

Can it be merged?

Click to reveal answer
Answer

No. The merge button is completely disabled. You must explicitly click 'Ready for review' to convert it into a normal PR before it can be merged.

Question

Trigger notifications?

Click to reveal answer
Answer

No. That is one of the main benefits. It doesn't spam your senior developers with emails until you officially mark it as ready.