What is the correct git config for working with GitHub pull requests?

前端 未结 4 2311
情话喂你
情话喂你 2021-02-18 21:44

I\'m aware of How can I check out a GitHub pull request?

While adding fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to .git/config does al

4条回答
  •  别跟我提以往
    2021-02-18 22:37

    You've only fetched branches, not pull requests. Add this to your config:

    fetch = +refs/pull/*/head:refs/pulls/origin/pr/*

    After that you can checkout a branch that points to a PR remote ref:

    git checkout -b "pr-123" pulls/origin/pr/123

    Generally, you can check out a ref if you've fetched it from the remote, so look through the git fetch command output and find the PR's ref name. That's what you should put in the checkout command. You should see something like:

    [new ref] refs/pull/123/head -> refs/pulls/origin/pr/123

    Note that you can substitute the pulls part for any custom prefix. You can now create a branch and point it to pulls/origin/pr/123, which is equivalent to refs/pulls/origin/pr/123 (see git refspec doc).

提交回复
热议问题