LinuxCommandLibrary

git-pr

Create GitHub pull requests from the command line

TLDR

Check out a specific pull request

$ git pr [pr_number]
copy

Check out a pull request from a specific remote
$ git pr [pr_number] [remote]
copy

Check out a pull request from its URL
$ git pr [url]
copy

Clean up old pull request branches
$ git pr clean
copy

SYNOPSIS

git pr [options]

PARAMETERS

-l, --list
    List existing pull requests for the repository. This allows you to see a summary of open pull requests, including their titles and numbers.

-n, --browse
    Opens the current branch's remote on github in your browser if there is no existing pr for it. If a pr exists for the branch, opens the pr on github.

-b, --base branch_name
    Specifies the base branch (e.g., `main`, `develop`) to which the pull request should be merged. If omitted, the default branch is used.

-t, --title title
    Sets the title of the pull request. If omitted, it might default to the current commit message or require manual input on GitHub.

-m, --message message
    Sets the message of the pull request. If omitted, it might default to the current commit message or require manual input on GitHub.

-d, --draft
    Create the pull request as a draft.

DESCRIPTION

The `git-pr` command is a utility designed to streamline the process of creating and viewing GitHub pull requests directly from the command line. It eliminates the need to navigate to the GitHub website by automating the creation of a pull request from your current branch. It typically works in conjunction with tools that manage GitHub authentication and repository information, like hub or gh. It aims to make the developer workflow more efficient by reducing context switching. The command typically determines the base branch (e.g., `main` or `develop`) and generates a URL that, when opened in a web browser, initiates the pull request creation process on GitHub. It usually also supports listing existing pull requests or viewing a specific pull request from the terminal.

Note: The specific functionality and available options might vary depending on the exact implementation and associated tools (like hub or gh) used.

CONFIGURATION

The behavior of `git-pr` is often influenced by configuration settings, such as the default base branch or the preferred text editor for composing pull request messages. These settings are usually managed through environment variables or configuration files specific to the associated tool (e.g., `hub` or `gh`).

AUTHENTICATION

To interact with the GitHub API, `git-pr` requires proper authentication. This is typically handled through API tokens or OAuth credentials managed by the underlying tool (e.g., `hub` or `gh`). Ensure that you have authenticated correctly before using `git-pr`.

HISTORY

The `git-pr` command has emerged as part of a broader trend toward enhancing developer productivity by integrating version control systems with collaborative platforms like GitHub. Tools like hub and gh sought to provide command-line interfaces that would streamline common GitHub tasks, including pull request creation. The specific `git-pr` command is often provided by these toolkits, offering a more direct and efficient way to initiate pull requests than manual web browser interaction. Its usage has grown with the increasing adoption of Git and GitHub workflows in software development.

SEE ALSO

git(1), hub(1), gh(1)

Copied to clipboard