55 points · by strix_varius · 3y ago · 77 comments
This is of course useless to me, and to any other developer who prefers to use standard tooling rather than proprietary lock-in stuff.
I don't begrudge Microsoft shipping a GH CLI as an optional thing, but shifting workflows away from the standard client is one of those changes that doesn't serve users, but rather serves some PM's KPIs.
EDIT: based on the "not on my machine" responses here, it's clear that I'm on some branch of an A/B test. These are the only three options now presented in my GH web UI - all the rest have disappeared (https://imgur.com/P7llsVo):
1. Checkout with the GitHub CLI
2. Checkout with GitHub Desktop
3. An ad for buying Codespaces for this public repo
For years, it's been the default command in a single-click "copy" field under the "code" dropdown in a PR, not because git is complicated and anyone needs to "look up" the command, but because that's a fast and efficient way to grab a branch.
Replacing the `git` single-liner with a `gh` single-liner does nothing for the user but make them dependent on the `gh` tool.
% gh pr checkout 132
RUN: git fetch origin refs/pull/132/head:joris_tests_20230119
From github.com:BurntSushi/toml-test
* [new ref] refs/pull/132/head -> joris_tests_20230119
RUN: git checkout joris_tests_20230119
Switched to branch 'joris_tests_20230119'
RUN: git config branch.joris_tests_20230119.remote origin
RUN: git config branch.joris_tests_20230119.pushRemote origin
RUN: git config branch.joris_tests_20230119.merge refs/pull/132/head
It just so happens that my local "gh" build prints this as I was debugging a problem some months ago and I never bothered building it again without this on account of being a lazy git.The entire reason I have "gh" on my system is to easily check out PRs and to set them up so I can push to them with a minimum of mucking about. I use it for noting else.
I do agree it would be nicer to also add the git commands (plural!), but I suspect they just didn't because it's multiple commands to get the same experience. That is: UI reasons, not anything sinister.
> proprietary "gh cli"
It's not "proprietary": https://github.com/cli/cli/blob/trunk/LICENSE
And as you can see in the output above, it's just a wrapper around some git commands. If you want to call this "proprietary" then you should also call tig, got, and other alternative interfaces to git "proprietary".
Fair. It is non-standard, published via Microsoft, and even named after the single product that it supports, but if we're splitting hairs it does technically have an open-source license. So I removed the term "proprietary."
Only the first two are actually important though (the rest smell like an antifeature to me in fact). I have them both as a single `git pr <remote> <PR>` alias:
[alias]
pr = !sh -c 'git fetch $1 pull/$2/head:pr-$1-$2 && git checkout pr-$1-$2' -
...and an equivalent for GitLab: [alias]
mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
You could easily hardcode remote to be "origin" and get what `gh` does.gh pr checkout 123
That's just for convienance. It does a few things...
1) looks up the pull request to find the proper repository and branch on it.
2) adds the repository if not already added
3) checks out the branch the PR is based on
How would you do that with just git?
I see gh pr checkout as a convenience. It just makes it less work.
git fetch origin refs/pull/123/head
git checkout FETCH_HEAD
This is actually somewhat preferable to me, because I don't always want to _checkout_ the PR. For example if I’m looking to integrate it into my branch via the CLI, its a git fetch origin refs/pull/123/head
git merge --ff-only (or whatever) FETCH_HEADI don't mind gh as an additional tool but OP's description suggests that Microsoft tries to replace git with gh entirely.
Doesn't seem quite true, as `git request-pull` command exists since 2005.
> the entire concept of a pull request is foreign to git
which is incorrect, since the the concept already existed, but was simply
> designed for email workflows
Indeed, GitHub-specific pull-requests didn't exist before GitHub, but that's a tautology, isn't it?
- an easy way to reset but I just switch to the command line for that - it's the only cli command I have to know
- decent submodule support (at least, as of the last time I was on a project that used these awful things)
- decent cherry picking (which I've only had to use when on project with awful merges - like when using submodules...)
I use the command line for everything but resolving merge conflicts. I really like the JetBrains UX for resolving them!
The only part of the commit response I care about is the URL to create/view a pull request. It’s pretty easy to ignore the rest.
The feature of gh I use most is `gh pr create`. It lets me combine the pushing of my current branch with creating a PR, allowing my to type the description using my text editor and has a nice interface for adding on reviewers etc. There's even a 'continue in a browser' button at the end if you want to add some screenshots.
It's an outstanding tool.
Of course it's easier than what you described, but that's not something you ever needed to do in order to checkout a pull request's branch; all you need to do it to checkout `pull/<ID>/head` from the repo PR has been made against - and that's what `gh pr checkout` does too.
(there's also `pull/<ID>/merge`, which contains the PR's branch already merged into target branch)
This works with GitLab too BTW, but you have to replace `pull` with `merge-requests`.
when cloning a repo you get 3 tabs instead of 2 before which are HTTPS,SSH,GH CLI
based on the gh command you wrote you were trying to checkout a branch related to a PR so i tried that on top there is now the `Checkout with github CLI` section but underneath it there is `Checkout with Git` with the HTTPS or SSH options
yes, they changed the layout and put their CLI on top (which came before microsoft btw, unrelated to them) but there is still the original workflow right there
Either OP is on some A/B bucket where they "deleted" git or OP didn't bother to look
Local has two options: "Checkout with the GitHub CLI" and "Checkout with GitHub Desktop."
Codespaces is an ad for buying codespaces for this repo (none exist).
EDIT: Never mind. OP was referring to checking out from the PR page, which does only show the GitHub CLI option.
On the contrary, HN is great because most users stick to the subject of discussions rather than devolving into ad-hominem attacks.
It's curious that your account was created exactly one minute after this post was posted, for precisely one insulting comment.
- - - -
MS has a long long history, any animosity they receive is well-earned. E.g.:
> "Embrace, extend, and extinguish" (EEE),[1] also known as "embrace, extend, and exterminate",[2] is a phrase that the U.S. Department of Justice found[3] that was used internally by Microsoft[4] to describe its strategy for entering product categories involving widely used standards, extending those standards with proprietary capabilities, and then using those differences in order to strongly disadvantage its competitors. https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis...
> The strategy and phrase "embrace and extend" were first described outside Microsoft in a 1996 article in The New York Times titled "Tomorrow, the World Wide Web! Microsoft, the PC King, Wants to Reign Over the Internet",[5]
https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis...
On at least three topics I've consistently found this to not be the case: Google, Microsoft, Cryptocurrency (also: Richard Stallman, suckless, but those come up less often).
I find that these threads often devolve pretty fast away from "the subject". I actually dislike all three of those things as well; I use none of their products save for GitHub and haven't for years. But that doesn't mean that everything these companies do is part of a sinister machiavellian plot to take over the world. And not everyone involved in crypto is a sociopathic scammer looking to steal your money, either, even though I think crypto overall is a net negative.
> It's curious that your account was created exactly one minute after this post was posted, for precisely one insulting comment.
I'm really not trying to "gotcha" here, but you're kind of proving my point with this remark.
I've been using GH at work and personally for a while now and i never wanted/needed to use the GH CLI/GUI, the IDE will cover you if you need it to.
If they really removed the easy to use copy button it would be annoying but calling it "extinguish" is definetly some HN warrior attitude. They didn't remove it though, just moved it a bit and OP is being a bit dramatic
There is no "default workflow" for git - Git can be used in a variety of ways; everyone has their own personal preference, and some of these workflows are shaped by interacting with systems like Github/Gerrit/etc.
Every place I've ever worked at has either:
- a home-grown wrapper around git to make common operations easy
- a recommended set of git aliases around common operations
The fact that Github has created their own to interact with their own system is a net win for individuals/organizations who would otherwise need to spend time scripting their own.Of all the capabilities of the Github CLI, `gh pr checkout` is the only one I use, because it makes it easy to fetch a PR locally by ID without configuring a remote per fork. I'm pretty glad I didn't have to write this myself.
> There is no "default workflow" for git
The default workflow, as in what Github promotes. Github's default, not git's. That's what's meant.
Wait, I'm a bit confused. Where you on the "branch" or on the "pull request" UI? If they replaced the instructions to check out an arbitrary branch, I could understand the outrage. But this looks like a command to check out a pull request. To my knowledge, there is no standard git command to do this. (Because "pull requests" are a github/gitlab/etc concept not a git concept as the sibling comments explained)
If they just added instructions for the github client for things you can't do with the normal git CLI, that seems perfectly reasonable to me.
git fetch origin pull/ID/head:BRANCH_NAME
From: https://docs.github.com/en/pull-requests/collaborating-with-...Sure, the whole workflow isn't a "standard Git workflow" but they could easily provide a command that works with the standard Git CLI.
And that's what they used to do there.
git doesn't care who hosts your code
Do all git mutations from command-line using `git`.
One useful tip is that you can go to github.com/<org-repo>/pull/<branch-name> rather than PR# and it will redirect.