usage

GitHub CLI 2.98.0

工具與目錄
在這頁

新功能 17 項

01

gh pr checkout 支援工作樹,切換 PR 不必動既有檔案

正寫程式寫到一半,同事突然請你幫忙測試別人的 PR(pull request,請求將程式碼合併進專案的提案)。⟦像在圖書館查資料時直接影印一份副本帶到另一張桌子讀,原桌上攤開的筆記完全不用收拾。⟧這正是輸入 gh pr checkout 123 --worktree 的時刻。加上 --worktree 旗標後,系統會替該 PR 建立獨立的工作樹(worktree,Git 讓同一專案平行開多份副本的功能)。你能在新資料夾查看與測試變更,目前的檔案與分支留在原地,不必先把未完成的修改暫存收起。

官方原文

Add --worktree flag to gh pr checkout by @tidy-dev in https://github.com/cli/cli/pull/13946

02

issue 搜尋加入 --search-type,支援語意與混合查詢

在專案裡搜尋 issue(議題,追蹤問題與建議的討論清單)時,以前只能比對一模一樣的關鍵字。⟦像找歌時忘記歌名,哼出大概的旋律能按感覺找;若還記得一小段歌詞,便把歌詞片段和旋律一起交給找歌的人。⟧gh search issues 現在新增了 --search-type 旗標,支援語意搜尋與混合搜尋兩種模式。當你記不清確切的錯誤文字時,輸入概念描述並加上 --search-type semantic,便能依背後涵義找出相近的討論;加上 --search-type hybrid 則會同時比對關鍵字與語意。

官方原文

Add --search-type flag for semantic and hybrid issue search by @michaeljacholke in https://github.com/cli/cli/pull/14006

@michaeljacholke made their first contribution in https://github.com/cli/cli/pull/14006

03

呼叫擴充套件自動帶入 GH_EXTENSION=1,身分識別更明確

撰寫或執行 GitHub CLI 擴充套件(extension,為 gh 新增自訂指令的附加工具)時,程式往往需要知道自己是怎麼被啟動的。⟦像員工佩戴公司發放的識別證進場,保全一眼就能確認他是從內部系統派來的,而不是自行闖入的外部訪客。⟧gh 現在在叫用任何擴充套件時,都會在環境變數(開程式之前預先塞給它的隱藏開關,一般使用者看不到)自動帶上 GH_EXTENSION=1。這讓擴充套件能藉由檢查該變數,確認自己正在被 gh 呼叫,並據此調整輸出格式或執行流程。

官方原文

Set GH_EXTENSION=1 when gh invokes an extension by @williammartin in https://github.com/cli/cli/pull/14072

04

gh release create 解析權限範圍時會去除空白

建立 Release 時,gh release create 需要從 X-Oauth-Scopes 標頭讀取權限範圍。現在解析時會去掉前後多餘空白,避免空白被當成權限名稱的一部分。修正處理的是標頭文字的辨識,讓權限範圍能按原本的名稱解讀。空白不會參與辨識。⟦像讀取名單前先把姓名旁多出的空格擦掉,才不會把同一個人誤認成另一位。⟧

官方原文

Trim spaces when parsing X-Oauth-Scopes in gh release create by @williammartin in https://github.com/cli/cli/pull/14065

05

七項 API 請求收攏至 api.Client,統一金鑰與發布通道

手邊的 GitHub CLI 指令照舊可用,不必因內部 API 連線架構重整而切換操作方式。⟦像一棟大樓原本各辦公室各自拉電話線對外聯絡,現在全面改由中央總機統籌轉接,線路更整齊且便於維護。⟧開發團隊將七項操作的 HTTP 請求全面收攏至統一的 api.Client(負責管理連線與驗證的共用用戶端模組)。涵蓋對象包含 deploy key、ssh key、gpg key 三類金鑰,以及 autolink 自動連結、extension 擴充套件、release 建立與 release 刪除。請求集中由共用用戶端發送後,程式碼結構更乾淨,連線行為也維持一致。

官方原文

Route deploy key requests through api.Client by @williammartin in https://github.com/cli/cli/pull/13989

Route ssh key requests through api.Client by @williammartin in https://github.com/cli/cli/pull/13994

Route gpg key requests through api.Client by @williammartin in https://github.com/cli/cli/pull/13997

Route autolink requests through api.Client by @williammartin in https://github.com/cli/cli/pull/14013

Route extension requests through api.Client by @williammartin in https://github.com/cli/cli/pull/14059

Route release creation through api.Client by @williammartin in https://github.com/cli/cli/pull/14062

Route release deletions through api.Client by @williammartin in https://github.com/cli/cli/pull/14077

06

垃圾 issue 分流併入 agentic 工作流程並恢復自動結案

專案把垃圾 issue 的分流整合進 agentic issue-triage 工作流程,並恢復自動關閉垃圾 issue。用來執行分流的 Action 相容性也已修正。分類與結案因而放在同一條處理路徑上,並確保這條路徑能相容執行。⟦這好比把廣告信篩選器裝進既有的收信流程:辨識出垃圾信後直接歸檔,不必再交給另一個不相容的分揀機。⟧

官方原文

Collapse spam triage into the agentic issue-triage workflow by @williammartin in https://github.com/cli/cli/pull/14027

Restore automatic spam issue closure by @williammartin in https://github.com/cli/cli/pull/14088

Fix issue triage action compatibility [skip changelog] by @tidy-dev in https://github.com/cli/cli/pull/14207

07

PR 審查須明確指定負責人

送出 PR(pull request,請求將程式碼合併進專案的提案)後,審查工作現在要求明確指定負責人。每一份等待審查的變更都要知道由誰接手,責任不再停留在未指派的狀態。這項規則只聚焦於審查歸屬的明確性。每份 PR 的審查責任都有明確歸屬。不再模糊。⟦這如同在任務看板的待辦卡上明確貼上負責人名條,避免卡片一直停在待辦清單卻沒人認領。⟧

官方原文

Require explicit PR review ownership by @williammartin in https://github.com/cli/cli/pull/14028

08

Dependabot 分流改為每小時執行,依程式碼可達性判斷

Dependabot(自動檢查相依套件更新的機器人)分流現在每小時執行。它的留言變短,判斷流程也改得更省成本、更果斷,並加入真正的程式碼可達性檢查:確認程式碼路徑是否真的能走到漏洞。它不只看到相依套件的問題,也會檢查程式實際能否觸及該問題。不是只看清單上的名稱。⟦這不是只看建築圖上有一扇失修的門,而是沿著走道實際確認能不能走到那扇門。⟧

官方原文

Slim down dependabot triage comments by @williammartin in https://github.com/cli/cli/pull/14019

Run Dependabot triage every hour by @sergiou87 in https://github.com/cli/cli/pull/14030

Make Dependabot triage cheaper and more decisive by @williammartin in https://github.com/cli/cli/pull/14079

Give Dependabot triage a real reachability check by @williammartin in https://github.com/cli/cli/pull/14087

@sergiou87 made their first contribution in https://github.com/cli/cli/pull/14030

09

AI 代理須套用 PR 範本,並釐清測試章節填寫規範

協助專案開發的 AI 代理準備提交 PR(pull request,請求將程式碼合併進專案的提案)時,現在必須依 AGENTS.md 規定的 PR 範本填寫。相關指引也進一步釐清了測試章節的填寫範圍,明確指出哪些驗證細節應記錄在該欄位。⟦像填寫制式的交接報告單,表格在驗收欄明確註記該登記哪些檢查項目,避免漏記關鍵細節。⟧這讓代理提交變更時有統一的交件標準,協助審查者迅速確認測試狀況。

官方原文

Tell agents to use the PR template in AGENTS.md by @williammartin in https://github.com/cli/cli/pull/14074

Clarify what belongs in the PR template's testing section by @williammartin in https://github.com/cli/cli/pull/14103

10

新增排程清理技術債技能,定期維護專案程式碼

專案維護久了,程式庫常累積零星的待辦標記、過時設定或待整理的舊結構,平時卻抽不出完整時間手動整理。專案現在為 AI 代理新增了排程清理技術債技能(tech debt burndown skill,定期處理專案累積技術債務的專用指令技能)。在排程設定中啟用並排定觸發時間後,代理便會按固定週期自動檢視並清理這些技術債。⟦像在大樓日誌裡排定例行大掃除,定期把倉庫堆積的雜物與舊箱子清運出去,不讓零碎雜物越積越多。⟧透過將清債任務標準化與排程化,專案能持續維持程式碼的整潔度與健康度。

官方原文

Add a scheduled tech debt burndown skill by @williammartin in https://github.com/cli/cli/pull/14095

11

程式碼審查技能更名為 code-review,簡化呼叫識別

專案調整了程式碼審查技能的命名,將原本的 cli-code-reviewer 正式更名為更簡短的 code-review。這項變更讓技能名稱更直覺且符合日常用法,去除多餘的前綴詞後也更容易被指令系統與開發者辨識。⟦像把辦公室門口冗長的「內部文件審查員室」標示,更換成簡潔明瞭的「審查室」門牌。⟧這次更名僅調整技能識別名稱,不影響原有的審查功能與運作機制。

官方原文

Rename cli-code-reviewer skill to code-review by @BagToad in https://github.com/cli/cli/pull/14116

12

Linux APT 套件庫改採雙金鑰簽署

Linux 系統的 APT 套件庫現在同時以兩把金鑰進行簽署。在 CI(持續整合,自動執行檢查的流程)中,團隊先前曾短暫加入驗證 Linux 套件庫簽署金鑰的臨時步驟,在確認簽署狀態正常後隨即撤回該臨時步驟。整項改動僅涉及雙金鑰簽署與臨時驗證步驟的清理。⟦像在同一份公文上同時蓋上兩枚印章以供雙重辨識,期間查驗處短暫增設了核印櫃檯,確認無誤後隨即撤除。⟧

官方原文

ci: add temporary step to verify Linux repo signing keys by @babakks in https://github.com/cli/cli/pull/14202

Revert "ci: add temporary step to verify Linux repo signing keys" by @babakks in https://github.com/cli/cli/pull/14203

chore: sign APT repository with both keys by @babakks in https://github.com/cli/cli/pull/13271

13

測試不再讀取本機認證與 Git 設定

你在自己的電腦上跑測試時,登入認證與 Git 設定本來就可能和其他人的不同,讓測試帶著個人環境的影子。這次調整把測試和本機的認證、Git 設定隔開,使測試執行時不再讀取這兩類本機資料。⟦像把實驗樣本放到專用的乾淨工作台上,只讓實驗指定的材料進場,不把研究員口袋裡的東西混進結果。⟧重點不是換掉你的認證或 Git 設定,而是讓測試不依賴它們。

官方原文

Isolate tests from local machine's auth and git configuration by @BagToad in https://github.com/cli/cli/pull/14128

14

部署驗證接受預發布標籤

部署流程驗證版本標籤時,現在接受預發布(pre-release,正式發布前使用的版本標籤)標籤。預發布標籤用來標示正式發布之前的版本;部署驗證會把這一類標籤視為可接受的輸入。⟦像活動入口除了正式票券,也核驗試營運場次的票券,兩種票都能通過入口。⟧這項調整只改部署驗證對標籤的接受條件,讓使用預發布標籤的部署流程不必在驗證處被擋下。

官方原文

Accept pre-release tags in deployment validation by @BagToad in https://github.com/cli/cli/pull/14193

15

以 reflect.Pointer 取代已淘汰的 reflect.Ptr

程式碼把已淘汰的 reflect.Ptr 改為 reflect.Pointer,完成一次 API(應用程式介面,程式用來呼叫功能的固定方式)替換。這不是新增另一種呼叫方式,而是將原先使用的過時名稱換成目前的名稱。⟦像把老舊規格的轉接頭換成現行規格,插在原本位置仍是為了完成同一段連接。⟧若你正在閱讀相關程式碼,看到 reflect.Pointer 就是在辨認這項替換後使用的 API。

官方原文

Use reflect.Pointer instead of deprecated reflect.Ptr by @williammartin in https://github.com/cli/cli/pull/14098

16

不需要清理時不再要求功能偵測註解

功能偵測(feature detection,先確認功能是否可用的做法)不需要清理時,現在不再要求清理註解。這條規則把是否需要清理當成是否提出註解要求的界線:有清理需要的地方可留下相應註解,沒有清理需要的地方則不因同一件事再被要求補註。⟦像工作單只在確有後續收尾工作時附上提醒;沒有待收尾的項目,就不多附一張提醒單。⟧改動的重點是刪除不必要的要求,讓註解要求和實際清理需要對齊。

官方原文

Don't ask for feature detection cleanup comments when not needed by @babakks in https://github.com/cli/cli/pull/14139

17

建置工具與相依套件升級,Dependabot 新增 aw-actions 群組

Dependabot 設定新增 aw-actions 群組,並更新 aw-actions、codeql-actions、sigstore-go、gRPC、go-containerregistry、actions/attest、azure/login、goldmark、protobuf、testify、x/crypto、lipgloss 與壓縮函式庫。Go 依序升至 1.26.6、1.26.7,CI 的 golangci-lint 升至 v2.12.2;gh-aw workflows 升至 v0.85.4,gh-aw-actions 升至 v0.87.1 並重新編譯 agentic workflows。⟦像維修清單逐項更換零件,連自動補貨規則與已組裝的工作單也一併更新。⟧

官方原文

Add aw-actions group to dependabot configuration by @babakks in https://github.com/cli/cli/pull/14123

chore(deps): bump github.com/sigstore/sigstore-go from 1.2.2 to 1.3.0 by @dependabot[bot] in https://github.com/cli/cli/pull/14047

chore(deps): bump the codeql-actions group across 1 directory with 3 updates by @dependabot[bot] in https://github.com/cli/cli/pull/14049

chore(deps): bump google.golang.org/grpc from 1.82.1 to 1.83.0 by @dependabot[bot] in https://github.com/cli/cli/pull/14048

chore(deps): bump github.com/google/go-containerregistry from 0.21.7 to 0.21.8 by @dependabot[bot] in https://github.com/cli/cli/pull/14066

chore(deps): bump actions/attest from 4.2.1 to 4.2.2 by @dependabot[bot] in https://github.com/cli/cli/pull/14100

chore(deps): bump azure/login from 3.0.0 to 3.0.1 by @dependabot[bot] in https://github.com/cli/cli/pull/14101

chore(deps): bump the codeql-actions group across 1 directory with 3 updates by @dependabot[bot] in https://github.com/cli/cli/pull/14091

chore(deps): bump github/gh-aw-actions/setup-cli from 0.83.4 to 0.85.4 by @dependabot[bot] in https://github.com/cli/cli/pull/14068

chore(deps): bump github.com/google/go-containerregistry from 0.21.8 to 0.21.9 by @dependabot[bot] in https://github.com/cli/cli/pull/14119

chore(deps): bump github.com/klauspost/compress from 1.19.1 to 1.19.2 by @dependabot[bot] in https://github.com/cli/cli/pull/14120

chore(deps): bump the aw-actions group with 2 updates by @dependabot[bot] in https://github.com/cli/cli/pull/14147

chore(deps): bump github.com/yuin/goldmark from 1.8.4 to 1.8.5 by @dependabot[bot] in https://github.com/cli/cli/pull/14029

chore(deps): bump actions/attest from 4.2.0 to 4.2.1 by @dependabot[bot] in https://github.com/cli/cli/pull/14050

Bump golangci-lint in CI to v2.12.2 by @williammartin in https://github.com/cli/cli/pull/14102

chore(deps): bump the aw-actions group with 2 updates by @dependabot[bot] in https://github.com/cli/cli/pull/14124

chore(deps): bump google.golang.org/protobuf from 1.36.11 to 1.36.12 by @dependabot[bot] in https://github.com/cli/cli/pull/14140

Upgrade gh-aw workflows to v0.85.4 by @tidy-dev in https://github.com/cli/cli/pull/14141

Bump Go to 1.26.6 by @github-actions[bot] in https://github.com/cli/cli/pull/14143

chore: bump go to 1.26.7 by @babakks in https://github.com/cli/cli/pull/14205

chore(deps): bump github.com/stretchr/testify from 1.11.1 to 1.12.1 by @dependabot[bot] in https://github.com/cli/cli/pull/14204

chore(deps): bump the codeql-actions group across 1 directory with 3 updates by @dependabot[bot] in https://github.com/cli/cli/pull/14169

chore(deps): bump golang.org/x/crypto from 0.54.0 to 0.55.0 by @dependabot[bot] in https://github.com/cli/cli/pull/14164

chore(deps): bump charm.land/lipgloss/v2 from 2.0.5 to 2.0.6 by @dependabot[bot] in https://github.com/cli/cli/pull/14166

Bump gh-aw-actions to v0.87.1 and recompile agentic workflows by @BagToad in https://github.com/cli/cli/pull/14210

修正 2 項

18

修正 RESTWithNext 錯誤型態,恢復 gh status 與 attestation 重試

查詢 gh status 時若遇到可重試的失敗,錯誤型態 RESTWithNext 的判斷曾讓重試失效。現在已修正,gh status 和 attestation(證明軟體產物來源與建置過程的數位簽署證明)都能重新嘗試,不會在第一次失敗後停住。⟦這像送件窗口發現回條有誤時,不再直接把整份文件退回,而是讓它回到處理隊伍再送一次。⟧

官方原文

Fix RESTWithNext error type, repairing gh status and attestation retries by @williammartin in https://github.com/cli/cli/pull/13988

19

修正非 TTY 環境的 gh project item-add 輸出

把 gh project item-add 放進腳本或管線時,命令並未連接互動式終端機,也就是非 TTY(沒有互動式終端機螢幕的環境)。這種情況的輸出已修正,讓命令在非互動環境也能正確輸出。這是自動化流程使用命令時會遇到的輸出修正。腳本可直接使用。⟦這如同寄件單不經服務台螢幕,而是直接進入自動分揀線時,仍會印出供機器讀取的正確標籤。⟧

官方原文

Fix project item-add output for non-TTY by @zwick in https://github.com/cli/cli/pull/14056