> ## Documentation Index
> Fetch the complete documentation index at: https://aysdog-mintlify-88c56c39.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and review pull requests with commitdog pr

> Create pull requests from feature branches with a diff viewer, then list, review, and merge them from main on GitHub, GitLab, Gitea, or Forgejo.

`commitdog pr` does different things depending on which branch you are on. On a feature branch it walks you through creating a pull request: you review a diff, enter a title and description, and commitdog creates the PR and opens it in your browser. On `main` or `master` it fetches all open PRs, lets you navigate them with keyboard shortcuts, view their diffs, and merge or close them without leaving the terminal.

`commitdog pr` works with GitHub, GitLab, Gitea, and Forgejo. It targets your project's primary platform, which is set during `commitdog init` and stored in the `.commitdog` file. If no primary platform is set, commitdog uses GitHub. On GitLab, the same flow creates and merges merge requests instead of pull requests.

<Note>
  Configure a token for your platform with `commitdog setup` before using this command. If commitdog does not find a token for the project's platform, it exits with an error telling you to run `commitdog setup`.
</Note>

## Usage

```bash theme={null}
commitdog pr
```

The behavior is determined automatically by your current branch.

<Tabs>
  <Tab title="Feature branch">
    ## Creating a PR

    <Steps>
      <Step title="Review the diff">
        commitdog shows an interactive list of files changed between your branch and the base branch, with insertion and deletion counts for each file. Navigate with `j`/`k` or the arrow keys and press `d` to view the inline diff for any file. Press `q` to proceed.
      </Step>

      <Step title="Enter a title and description">
        commitdog pre-fills the title with your last commit subject. Press Enter to accept it or type a replacement. The description is optional.

        ```text theme={null}
          creating PR: feat/auth → main

          title › feat(auth): add refreshToken and verifyToken
          description (optional) ›

          [enter] confirm  [q] cancel ›
        ```
      </Step>

      <Step title="PR is created and opened">
        commitdog calls your platform's API and prints the PR number and URL:

        ```text theme={null}
          ✓ PR #42 created
          https://github.com/you/repo/pull/42

          open in browser? [Y/n] ›
        ```

        Press Enter or `y` to open the PR in your default browser.

        On GitLab, commitdog creates a merge request and prints it with GitLab's `!` numbering:

        ```text theme={null}
          ✓ MR !42 created
          https://gitlab.com/you/repo/-/merge_requests/42

          open in browser? [Y/n] ›
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Main branch">
    ## Reviewing PRs

    When you run `commitdog pr` on `main` or `master`, commitdog fetches all open PRs (or merge requests on GitLab) and displays them in a scrollable list:

    ```text theme={null}
      open PRs — you/repo

    › #42   feat/auth       → main       feat(auth): add refreshToken...   @alice
      #38   fix/login-bug   → main       fix: resolve session timeout...   @bob
    ```

    ### Keyboard shortcuts

    | Key        | Action                            |
    | ---------- | --------------------------------- |
    | `j` or `↓` | Move selection down               |
    | `k` or `↑` | Move selection up                 |
    | `d`        | View the diff for the selected PR |
    | `m`        | Merge the selected PR             |
    | `q`        | Quit                              |

    ### Merging a PR

    Pressing `m` on a selected PR opens the merge method picker. All four platforms offer the same three methods. On GitLab, the rebase option calls GitLab's rebase API instead of a merge.

    ```text theme={null}
      merge PR #42 — feat(auth): add refreshToken and verifyToken

      1  merge commit
      2  squash merge
      3  rebase merge

      [1/2/3] pick ›
    ```

    After merging, commitdog asks whether to delete the feature branch:

    ```text theme={null}
      ✓ merged PR #42 into main

      delete feat/auth branch? [Y/n] ›
    ```

    Selecting yes deletes both the remote branch (via your platform's API) and the local branch. commitdog then checks out the base branch and pulls the latest changes automatically:

    ```text theme={null}
      pulling main...
      ✓ up to date
    ```
  </Tab>
</Tabs>
