loading...

I use the GitHub Desktop app for one thing. Am I doing this wrong?

ben profile image Ben Halpern ・1 min read

When I go to review a PR that cannot be purely evaluated on the code, I click this link:

I've found that to be the most seamless way to check out the branch and give the working app a manual look-see. Otherwise I use the git CLI, but I've found this to be my favorite way so far.

But it seems off to me. I have this app running all the time for this singular purpose. It also seems off because I have to scroll all the way to the bottom of the page and click a text link. If this were the appropriate behavior, it would make sense to me that this button would look a lot more like the "Squash and Merge" button next to it.

I know this has worked for me, but I'm just curious if I'm missing something.

Posted on Jan 26 '19 by:

ben profile

Ben Halpern

@ben

A Canadian software developer who thinks he’s funny. He/Him.

Discussion

markdown guide
 

Someone else mentioned hub github.com/github/hub but thought I'd provide an example! Once you have hub setup and authenticated with your Github account you can use a command like the following the checkout PR#123 for example

hub pr checkout 123

Not sure if this is easier than the web ui, since you have to find the PR number first, but at least that doesn't require scrolling all the way down the page!

 

Cool. I have hub installed, I guess I just never used it this way. I'm curious whether the mental overhead of remembering the number and switching applications like that will be the right solution. I do quite like clicking a button, but I'll examine this as an approach.

Now that I'm thinking about it, this might be something I could do entirely in VSCode.

I just installed this, and I will give it a try:

Microsoft / vscode-pull-request-github

GitHub Pull Requests for Visual Studio Code

Review and manage your GitHub pull requests directly in VS Code

This extension allows you to review and manage GitHub pull requests in Visual Studio Code. The support includes:

  • Authenticating and connecting VS Code to GitHub.
  • Listing and browsing PRs from within VS Code.
  • Reviewing PRs from within VS Code with in-editor commenting.
  • Validating PRs from within VS Code with easy checkouts.
  • Terminal integration that enables UI and CLIs to co-exist.

Demo

Getting Started

It's easy to get started with GitHub Pull Requests for Visual Studio Code. Simply follow these steps to get started.

  1. Make sure you have VSCode version 1.27.0 or higher.
  2. Download the extension from the marketplace.
  3. Reload VS Code after the installation (click the reload button next to the extension).
  4. Open your desired GitHub repository.
  5. Go to the SCM Viewlet, and you should see the GitHub Pull Requests treeview. On the first load, it will appear collapsed…
 

That VS Code plugin could likely do what you need. If it does and that is all you use the Github desktop app for I would say replace it. But, if you like working the other way I would say stick with it. It’s hard to argue with the fact that it works and you get your desired results. I don’t think you should consider your approach “wrong” or “inappropriate” because just like most things with development there is multiple ways to get work done and that’s okay.

 

This is what I was going to suggest. I absolutely love this extension for this use case. One of my awesome-* repos used to have merge conflicts with basically every PR because of how I initially structured it (an OSS contributor came and restructured it to make this not happen anymore 💖) and this extension saved so much time when I started using it.

 

I use hub for this too, all the time. You can also just copy and paste the URL to the GitHub PR page and use that instead of the issue number in the hub checkout <whatever> command line.

 

If it works, it works!

I stopped using GitHub Desktop a while ago because it was oversimplifying some parts of git, which could cause weird errors (typically around merge conflicts, if I recall) and usually required the typical fix. I've since happily used GitKraken, which I find to be a phenomenal git GUI. (Yeah, yeah, not a real programmer, whatevs.)

 

What do you mean by can not be purely evaluated by reviewing the code? I’ve never used the desktop app. What does clicking that link help you achieve on the app?

If this is what you use to perform manual tests before merging you can just checkout the branch locally on your machine (from the CL) and then execute to test.

 

I'm not clear on this bit either.

 

To review PRs, I use what @maestromac showed me, which is running the git command:

git fetch upstream pull/pull-request-issue/head:name-of-branch-locally

So for example:

git fetch upstream pull/1579/head:1579-share-dropdown

I can never remember the full command though so I made it into a bash function:

rvpr() {
  # check if second argument was given
  if [ -z "$2" ]; then
    git fetch upstream pull/$1/head:$1-pull-request
  else
    git fetch upstream pull/$1/head:$1-$2
  fi
}

# to be used like:
rvpr 1579 share-dropdown
#=> an alias for git fetch upstream pull/1579/head:1579-share-dropdown
 

I personally use lab for GitLab at work, which is inspired by hub for GitHub. It let's you manage merge requests via the CLI. If you don't want to go into the UI/website you don't have to. It's not actually a solution or answer to your question, but it is an alternative method that would achieve the same goal (working entirely in the CLI isn't for everyone!).

As for the GitHub desktop client, if it works for you, keep using it! It might also be possible to build yourself a lighter weight tool that does the same thing, but that's a lot more effort 😛

 

Meanwhile, here I am only using Github Desktop at home to clone repos while I use Gitkracken for checking out merge requests haha. I'm starting to get in the habit of using Gitkracken for cloning, too, so I should probably just uninstall Github Desktop. Gitkracken supports multiple web origin types, so it's easier to keep GitLab and GitHub in one spot.

 

Not sure this is exactly your use case, but I hacked together a way to checkout a PR branch in a local repo by clicking the "Open in Github Desktop" application. It's pretty hacky, but it works:

wuz / open-in-local-git

Use "Open in Github Desktop" to check out the branch in your local repo.

open-in-local-git

Use "Open in Github Desktop" to check out the branch in your local repo.

This is an electron app the overrides the Github desktop application protocol handler to checkout a git branch on your local machine when you click the "Open in Github Desktop" link on a Github Pull Request.

Caution: this might replace the normal Github Desktop functionality. If you use it for anything other than the "Open in Github Desktop" link you probably don't want to use this!

Inspired by this thread on dev.to

Head over to Releases to download!


If people are interested/this works for them, I'll keep up on the issues and try to add some new features.

 

Perhaps it is such a small link because the intended way to merge pull requests (according to GitHub) is probably from GitHub Desktop, without the browser step.

 

There are so many things about git which baffle or confuse me that I'm not sure it fixes more problems than it creates.