+4

GitHub/others: allow to easily check out pull request source

Bugged 6 years ago updated by Daniel Siegl 8 months ago 3

Hi,

Can you put a button on his small menu, to allow me checkout on the pull request on a branch locally?

I would like to perform some updates on it, but first I need to checkout on it locally.

Image 244


Currently I open the command line and run: 

https://help.github.com/articles/checking-out-pull-requests-locally/

> git fetch lark pull/236/head:pull/236

From https://github.com/lark-parser/lark

 * [new ref]         refs/pull/236/head -> pull/236

> git checkout pull/236

Switched to branch 'pull/236'

I found a trick using only UI, athough it's not one-step yet:

1. Toggle the PR to show it in the log view

2. Right-click > Reveal commit

3. Double-click or right-click > Check out on the revealed commit (! you must click on the pulls/.../ID badge, not the grayed out text on the right, or it won't work !)

4. You can choose to work read-only for quick testing, or create a branch to keep working on the PR

I also need this feature.

One important thing is when doing the checkout, the tracked branch must be set to the PR branch, so is possible to eventually push commits to the PR branch. This is how the Pull Request vscode extension works: it lists the available PR, when you right click, there's a 'Checkout' command, when executing 'Checkout' command the tracked branch of local branch is set to the PR branch


> I found a trick using only UI, athough it's not one-step yet:

This trick does not set the tracked branch

We should distinguish between PR with source in the same repo or from a different fork:


* In the same repo: it would be best if one could easily check out the source branch, where testing, work, and pushing can be done.
* From a different fork: here, one can only check out one specific commit. This results in a detached HEAD, which many may be hard for a lot of people. I would not offer this in the UI at first, but it is okay in the log.

What would be the best preconditions to enable this?

I would only provide it on the PR objects, not where it shows in the screenshot (the local branch may not even exist).
Ideally, it would be the existing "Check Out" label. This currently does not work on PR objects (currently disabled). This also ensures that Accelerators work properly.