What's New
Selecting a default repository
When running a gh command for the first time in a local git repository that has multiple git remotes, gh used to interactively ask Which should be the base repository? so that the user may choose the git remote to default to when making queries to GitHub repositories. This had several problems:
- Some users did not fully understand what they are being asked to choose;
- The term “base repository” isn't an established GitHub term, except in the context of Pull Requests;
- Once chosen, the only way to undo or change the choice made was to manually edit
.git/configin the local repository.
The new behavior is as follows:
- gh commands in a repository with multiple remotes will now error out until a default has been chosen.
- The new
gh repo set-defaultcommand can be used to select a default, view the selected value, or undo the selection altogether.
Thank you @bchadwic and @vilmibm! #4859 #6738
Internal git operations are now always authenticated
Previously, it could be confusing that a properly authenticated gh repo clone <repo> command could fail with a prompt for GitHub password. The underlying reason was that gh repo clone would shell out to git clone <url>, and from then on the authentication was entirely up to git's own credential management. If git wasn't set up to authenticate to GitHub, this could result in a generic password prompt, which appeared as if it was coming from gh.
The best general solution for setting up git to use credentials from GitHub CLI is to run gh auth setup-git. However, in this release, gh ensures that all underlying git operations are authenticated by gh, even if git on its own wasn't configured with a credential helper.
The way this works is by injecting extra configuration arguments when shelling out to git:
git -c credential.helper='!gh auth git-credential' clone <url>
The gh api command now accepts nested JSON parameters
The gh api command is similar to the popular curl tool, but with JSON encoding & parsing support and with built-in GitHub authentication. Sending JSON POST parameters was as easy as:
gh api <endpoint> -f 'param1=value1' -f 'param2=value2'Now there is also a way to send nested JSON objects and arrays via a special brackets syntax when specifying field names:
gh api <endpoint> -f 'head[branch][name]=main'
gh api <endpoint> -f 'labels[]=bug' -f 'labels[]=priority-1'Other goodies
- Add
issue lock/unlockandpr lock/unlockcommands by @chemotaxis in #5333 release create: add--verify-tagflag by @luanzeba in #6632release create: add--exclude-pre-releasesflag by @owenvoke in #6625repo create: prompt for repository owner in interactive mode by @twelvelabs in #6578repo edit: add--allow-update-branchflag by @browniebroke in #6706extension upgrade: show version change information by @despreston in #6647- Codespaces: Use
-Rfor--reposhorthand and deprecate-rby @cmbrose in #6725 codespace create: allow setting display name for the new codespace by @despreston in #6739alias list: change output format to YAML by @ptforness in #6603- JSON export improvements:
- Add
authorinformation inpr listJSON output by @hirasawayuki in #5049 - Add
isDrafttosearch prsjson options, matchingpr viewby @mgabeler-lee-6rs in #6704 - Expose commit SHA in PR reviews JSON export by @mislav in #6646
- Add
What's Changed
ap: avoid sending empty JSON body when no params for a non-GET request by @mislav in #6775release: more resilient release creation and asset management by @mislav in #6667pr create: exclude the current user from potential reviewers by @nsmag in #6464codespace ports: use new domain in URLs of forwarded ports by @jshorty in #6705- Document installing GitHub CLI in Codespaces by @mislav in #6653
- docs: Update installation instructions for WinGet by @vegerot in #6716
- Update Cobra and make use of its new command grouping by @mislav in #6589
- Update go-gh to v1.0.0 by @samcoe in #6618
- Bump mislav/bump-homebrew-formula-action from 1 to 2 by @dependabot in #6634
- Upgrade to Go 1.19 by @mislav in #6723
- Use Prompter in
prpackage by @vilmibm in #6451 - Use Prompter in
releasecommand by @vilmibm in #6711 - Linter fixes by @samcoe in #6722
- Bump goreleaser/goreleaser-action from 3 to 4 by @dependabot in #6727
- Fix signing Windows exe on release by @mislav in #6776
New Contributors
- @luanzeba made their first contribution in #6632
- @twelvelabs made their first contribution in #6578
- @vegerot made their first contribution in #6716
- @ptforness made their first contribution in #6603
Full Changelog: v2.20.2...v2.21.0