Can you issue pull requests from the command line on GitHub?

后端 未结 9 2578
花落未央
花落未央 2020-11-28 17:48

It seems like you have to interact with github.com to initiate a pull request. Is this so?

相关标签:
9条回答
  • 2020-11-28 18:45

    With the Hub command-line wrapper you can link it to git and then you can do git pull-request

    From the man page of hub:

       git pull-request [-f] [TITLE|-i ISSUE|ISSUE-URL] [-b BASE] [-h HEAD]
              Opens a pull request on GitHub for the project that the "origin" remote points to. The default head of the pull request is the current branch. Both base and head of the pull request can be explicitly given in one  of  the  following  formats:  "branch",  "owner:branch",
              "owner/repo:branch". This command will abort operation if it detects that the current topic branch has local commits that are not yet pushed to its upstream branch on the remote. To skip this check, use -f.
    
              If TITLE is omitted, a text editor will open in which title and body of the pull request can be entered in the same manner as git commit message.
    
              If instead of normal TITLE an issue number is given with -i, the pull request will be attached to an existing GitHub issue. Alternatively, instead of title you can paste a full URL to an issue on GitHub.
    
    0 讨论(0)
  • 2020-11-28 18:46

    In addition of github/hub, which acts as a proxy to Git, you now (February 2020) have cli/cli:

    See "Supercharge your command line experience: GitHub CLI is now in beta"

    Create a pull request

    Create a branch, make several commits to fix the bug described in the issue, and use gh to create a pull request to share your contribution.

    By using GitHub CLI to create pull requests, it also automatically creates a fork when you don’t already have one, and it pushes your branch and creates your pull request to get your change merged.


    And in April 2020: "GitHub CLI now supports autofilling pull requests and custom configuration"

    GitHub CLI 0.7 is out with several of the most highly requested enhancements from the feedback our beta users have provided.
    Since the last minor release, 0.6, there are three main features:

    • Configure gh to use your preferred editor with gh config set editor [editor].
    • Configure gh to default to SSH with gh config set git_protocol ssh.
      The default Git protocol is HTTPS.
    • Autofill the title and body of a pull request from your commits with gh pr create --fill.

    So:

    gh pr create --fill
    
    0 讨论(0)
  • 2020-11-28 18:47

    I'm using simple alias to create pull request,

    alias pr='open -n -a "Google Chrome" --args "https://github.com/user/repo/compare/pre-master...nawarkhede:$(git_current_branch)\?expand\=1"'
    
    0 讨论(0)
提交回复
热议问题