This error occurs when you attempt to merge a GitHub pull request that is still marked as a draft. Draft pull requests are intentionally blocked from merging to indicate work-in-progress. You must mark the PR as 'Ready for review' before it can be merged.
This error indicates that you're trying to merge a pull request that is currently in draft mode on GitHub. Draft pull requests are a feature that allows developers to open a PR early to share work-in-progress without signaling that the code is ready for review or merge. When a pull request is in draft state: 1. **The merge button is disabled**: GitHub prevents merging to protect the target branch from incomplete code 2. **Review requests may be limited**: Depending on repository settings, formal code reviews might not be requested automatically 3. **Status checks may still run**: CI/CD pipelines typically execute on draft PRs, allowing you to validate changes before marking ready 4. **The PR is visually marked**: A gray "Draft" label appears next to the PR title Draft PRs are useful for: - Sharing early work for informal feedback - Running CI checks before requesting formal review - Indicating that a PR is blocked or waiting on dependencies - Preventing accidental merges of incomplete features The error message "Pull request is in draft state and cannot be merged" tells you that someone (or automation) attempted to merge a PR before it was marked as ready for review. This is expected behavior designed to protect your codebase.
The most common fix is to mark the draft PR as ready for review. You can do this through the GitHub web interface:
1. Navigate to your pull request on GitHub
2. Scroll down to the bottom of the PR description
3. Click the green "Ready for review" button
4. The PR will change from draft to open state
The button is located in the merge section area and will replace the disabled merge controls with the standard merge options once clicked.
Note: Only the PR author or users with write access to the repository can mark a draft PR as ready.
If you prefer the command line, use the GitHub CLI to convert a draft PR:
# Mark a specific PR as ready for review
gh pr ready 123
# Mark the PR for the current branch as ready
gh pr ready
# You can also specify the repository
gh pr ready 123 --repo owner/repoAfter running this command, the PR will be converted from draft to open state and can be merged (assuming all other requirements are met).
Verify the change:
# Check the PR status
gh pr view 123
# Look for "State: OPEN" instead of "State: DRAFT"For automation or scripts, you can use the GitHub REST API to mark a PR as ready:
# Using curl with a personal access token
curl -X PATCH \
-H "Authorization: Bearer YOUR_GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER \
-d '{"draft": false}'Or using the GraphQL API for more control:
# Using GitHub CLI with GraphQL
gh api graphql -f query='
mutation {
markPullRequestReadyForReview(input: {pullRequestId: "PR_NODE_ID"}) {
pullRequest {
isDraft
}
}
}
'To get the PR node ID:
gh pr view 123 --json id --jq '.id'If you have GitHub Actions or other automation that merges PRs, update it to check for draft state first:
# .github/workflows/auto-merge.yml
name: Auto Merge
on:
pull_request:
types: [opened, synchronize, ready_for_review]
jobs:
auto-merge:
runs-on: ubuntu-latest
# Skip draft PRs entirely
if: github.event.pull_request.draft == false
steps:
- name: Enable auto-merge
run: gh pr merge --auto --squash "${{ github.event.pull_request.number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Key points:
- Use the ready_for_review event type to trigger when drafts become ready
- Add if: github.event.pull_request.draft == false condition
- The workflow will run again when the PR is marked ready
If Dependabot, Renovate, or other bots are creating draft PRs, configure them to open regular PRs instead:
For Renovate (renovate.json):
{
"draftPR": false
}For Dependabot (dependabot.yml):
Dependabot doesn't create draft PRs by default. If you're seeing draft PRs, check if:
1. A GitHub Action is converting them to drafts
2. Branch protection rules are involved
3. A custom workflow is modifying PR state
For GitHub Actions that create PRs:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
draft: false # Explicitly set to false
title: "Update dependencies"Some repository settings can affect draft PR behavior:
1. Navigate to repository Settings > General
2. Look for pull request settings
3. Check if there are any required workflows that might affect draft state
Branch protection considerations:
- Draft PRs can still trigger status checks
- Required reviews can be requested on draft PRs
- The merge restriction applies regardless of passing checks
To verify current settings via CLI:
# View branch protection rules
gh api repos/{owner}/{repo}/branches/main/protection
# Check PR details including draft status
gh pr view 123 --json isDraft,state,mergeableIf mergeable shows as BLOCKED and isDraft is true, you need to mark the PR as ready.
To prevent this issue in the future, be mindful when creating PRs:
GitHub Web Interface:
- When creating a PR, there's a dropdown arrow next to "Create pull request"
- Clicking the arrow reveals "Create draft pull request" option
- Make sure to select the correct option
GitHub CLI:
# Create a regular PR (not draft)
gh pr create --title "My feature" --body "Description"
# Create a draft PR (intentionally)
gh pr create --draft --title "WIP: My feature"Git push with hub:
# Regular PR
hub pull-request -m "My feature"
# Draft PR
hub pull-request -d -m "WIP: My feature"If you frequently create drafts accidentally, consider:
- Using PR templates that remind about draft status
- Adding a pre-merge checklist
- Using branch naming conventions (e.g., wip/ prefix for draft-intended branches)
### When to Use Draft Pull Requests
Draft PRs are valuable in specific workflows:
Early Feedback Pattern:
1. Open draft PR with initial implementation
2. Request informal feedback from teammates
3. Iterate based on comments
4. Mark ready when feature is complete
5. Request formal code review
CI-First Development:
1. Open draft to trigger CI pipelines early
2. Fix any issues that CI catches
3. Mark ready only when all checks pass
4. Reduces review cycles
Dependency Chains:
When PR B depends on PR A:
1. Open PR A normally
2. Open PR B as draft (based on A's branch)
3. Keep B as draft until A is merged
4. Rebase and mark B ready
### API Behavior with Draft PRs
When using the GitHub API, draft state affects several operations:
| Operation | Draft PR | Regular PR |
|-----------|----------|------------|
| Create | draft: true | draft: false or omit |
| Merge | Returns 405 error | Proceeds normally |
| Request review | Works, but may be optional | Works normally |
| Approve | Can approve | Can approve |
| Status checks | Run normally | Run normally |
GraphQL Mutations:
# Convert to draft
mutation {
convertPullRequestToDraft(input: {pullRequestId: "..."}) {
pullRequest { isDraft }
}
}
# Mark ready for review
mutation {
markPullRequestReadyForReview(input: {pullRequestId: "..."}) {
pullRequest { isDraft }
}
}### Webhooks and Draft PRs
GitHub sends specific webhook events for draft state changes:
{
"action": "ready_for_review",
"pull_request": {
"draft": false,
"state": "open"
}
}Actions that convert to draft trigger converted_to_draft action.
Configure workflows to listen for these events:
on:
pull_request:
types: [ready_for_review, converted_to_draft]### Permissions Required
| Action | Required Permission |
|--------|---------------------|
| Mark own PR ready | Author (any permission) |
| Mark others' PR ready | Write access to repo |
| Convert to draft | Author or write access |
| Merge (when ready) | Write access + passing checks |
### Auto-Merge with Draft PRs
GitHub's built-in auto-merge feature works with draft PRs:
1. Enable auto-merge on a draft PR
2. Configure merge method (squash, merge, rebase)
3. Auto-merge queues but doesn't execute
4. When marked ready + checks pass, merge executes
# Enable auto-merge on a draft PR
gh pr merge 123 --auto --squash
# PR won't merge until:
# 1. Marked as ready
# 2. All required checks pass
# 3. Required reviews approved### GitHub Enterprise Considerations
On GitHub Enterprise Server:
- Draft PR feature available since GHES 2.17
- GraphQL mutations may differ slightly
- Check your GHES version for API compatibility
Enterprise Cloud organizations may have policies around:
- Required status checks before marking ready
- Mandatory draft period for certain branches
- Automated PR state management via Actions
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server