4

I have a public GitHub repository.

Someone submitted a pull request.

I would like to test and edit pull request in Visual Studio Code and push suggested edits to existing pull request so they can be discussed and merged on GitHub.

I use Visual Studio Code as my code editor, but question isn’t specific to Visual Studio Code.

Is this possible using git command?

sunknudsen
  • 6,356
  • 3
  • 39
  • 76

2 Answers2

3

I have to admit that I never tried it, but as far as I could see, you need to:

  1. Install the GitHub Pull Requests and Issues from the Marketplace.
  2. Select your pull request from the list within Visual Studio Code.
  3. Click "Checkout".
  4. Review the pull request and finish your review.

There is also a cool demo on the code.visualstudio.com blog .

Christian
  • 4,902
  • 4
  • 24
  • 42
  • Thanks for sharing Christian! Is it possible to do this using `git` alone? – sunknudsen Aug 23 '21 at 21:08
  • No idea what you mean by git alone. You asked about Visual Studio Code and Github, I just found another great feature, which I will try tomorrow: [Creating Pull Requests](https://github.blog/2019-01-07-create-pull-requests-in-vscode/#:~:text=To%20create%20pull%20requests%20in,ve%20opened%20your%20pull%20request.) :) – Christian Aug 23 '21 at 21:13
  • Oh… sorry for confusion… I updated question. I am asking about editing PR using desktop code editor vs GitHub PR web editor. – sunknudsen Aug 23 '21 at 21:18
  • 1
    Oh ok, so my answer is outdated now. Sorry, for not being able to help. Working with Git/GitHub and pulll requests for a few years now. Afaik, you can only push commits to the branch for which the pull request has been created, and you cannot submit suggestions using git. Any suggestions and originally included code gets overwritten/outdated. Interested in hearing other people's thoughts. – Christian Aug 23 '21 at 21:23
  • How about for forked repo? I mean if someone creates a PR from his forked repo to my main repo, how can I review directly from my vscode? – IFTEKHAR I ASIF Sep 08 '22 at 06:43
2

Since the Pull Request is from a fork, you can’t push changes to the PR yourself unless you also have access to the fork, or the PR creator grants you permission. You can make suggestions in a PR review though.

However, you can check out and test the PR yourself using git:

git fetch origin refs/pull/2/head:pr/2
git checkout pr/2

Source: GitHub clone from pull request?

cmbuckley
  • 40,217
  • 9
  • 77
  • 91