Visual Studio 2022: Work with PRs locally After Functionality Was Removed

VS2022 is a huge step forward, however one of my favourite functionalities - checking out PRs locally, modifying, and reviewing them is now lost. When I’m in .NET and using Rider this is still supported, but I love VS for C++ development much more.

First, install gh (I use scoop).

> scoop install gh
Installing 'gh' (2.3.0) [64bit]
gh_2.3.0_windows_amd64.zip (7.0 MB) [=========================================================================] 100%
Checking hash of gh_2.3.0_windows_amd64.zip ... ok.
Extracting gh_2.3.0_windows_amd64.zip ... done.
Linking ~\scoop\apps\gh\current => ~\scoop\apps\gh\2.3.0
Creating shim for 'gh'.

then run gh auth login to authenticate.

And then you can just do

> gh pr checkout 126
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 9 (delta 7), reused 9 (delta 7), pack-reused 0
Unpacking objects: 100% (9/9), 763 bytes | 16.00 KiB/s, done.
From https://github.com/MagicAndre1981/config
 * [new branch]      dotnet6    -> MagicAndre1981/dotnet6
Switched to a new branch 'dotnet6'
Branch 'dotnet6' set up to track remote branch 'dotnet6' from 'MagicAndre1981'.

where 126 is PR number. Your local current branch will now switch to remote PR branch, so you can make modifications as needed and push to the requester’s remote.

Unfortunately I haven’t found a way to review PRs, but that’s a good start.

Have a question⁉ Contact me.


git

205 Words

2021-12-09