跳到主内容
精选80GitHub Changelog客户端

GitHub CLI v2.99.0:支持在 Issue、PR 和评论中直接上传媒体文件

GitHub CLI: Media in issues, pull requests, and comments

原文
推荐理由

CLI 重度用户必看:v2.99.0 补齐了长期缺失的媒体附件能力,以后提 Issue 和 PR 可以直接甩截图了,强烈建议升级以优化工作流。

GitHub CLI now has a repeatable --attach flag that uploads a local image or video and references it inline in an issue, pull request, or comment body.

GitHub CLI 现在支持可重复使用的 --attach 标志,用于上传本地图片或视频,并在 issue、pull request 或评论正文中以内联方式引用。

This is now generally available to all users on GitHub across all plans. You just need to update gh to v2.99.0.

该功能现已面向 GitHub 所有计划的所有用户全面开放。你只需将 gh 更新至 v2.99.0 即可。

Why this matters?

为什么这很重要?

Some things are easier to show than to describe (i.e., a UI bug, a rendered result, an error on screen). Previously, gh only wrote text, so adding an image or video to an issue or pull request meant stopping to open the browser, drag the file into the comment box, and copy the result back. Now, gh can attach images and videos directly from the command line.

有些内容展示起来比描述更容易(例如 UI 缺陷、渲染结果、屏幕上的错误)。此前,gh 仅支持文本输出,因此向 issue 或 pull request 添加图片或视频意味着需要暂停操作,打开浏览器,将文件拖入评论框,再将结果复制回来。现在,gh 可以直接从命令行附加图片和视频。

--attach puts the image in the same command that writes Markdown. File the bug, and the screenshot lands with it, so the issue shows the actual problem the first time. Open the pull request with a before and after, and the reviewer sees the change instead of pulling the branch to check. Your coding agents get this too, so they can show a result rather than describe it.

--attach 将图片放入编写 Markdown 的同一命令中。提交 bug 时,截图会随之一同提交,使 issue 首次显示实际存在的问题。创建包含前后对比的 pull request 时,审查者可以直接看到变更,而无需拉取分支进行检查。你的编码代理也能获得此功能,从而能够展示结果而非仅仅描述它。

Capabilities

功能特性

  • Attach from commands that write Markdown text: --attach is repeatable and works on gh issue create, gh issue edit, gh issue comment, gh pr create, gh pr edit, and gh pr comment.
  • Keep your Markdown as written: A local path already referenced in the body is rewritten in place, so ![alt](./login.png) keeps its alt text and becomes the uploaded asset. Anything attached but never referenced is appended at the end.
  • Post images and video: PNG, JPEG, GIF, WebP, SVG, MP4, MOV, and WebM are all supported.
  • Describe what you attach: Alt text follows the path after #, as in --attach './login.png#The login error state'. Omit it and gh falls back to the filename.
  • 在编写 Markdown 文本的命令中使用 --attach:--attach 是可重复使用的,适用于 gh issue create、gh issue edit、gh issue comment、gh pr create、gh pr edit 和 gh pr comment。
  • 保持 Markdown 原样:正文中已引用的本地路径会在原地重写,因此 ![alt](./login.png) 会保留其 alt 文本并变为上传的资源。任何被附加但从未引用的内容将被追加到末尾。
  • 发布图片和视频:支持 PNG、JPEG、GIF、WebP、SVG、MP4、MOV 和 WebM。
  • 描述你附加的内容:alt 文本跟随 # 后的路径,例如 --attach './login.png#登录错误状态'。如果省略,gh 将回退使用文件名。

Security and access controls

安全与访问控制

Uploads authenticate with the common token types gh already uses, either the OAuth token from gh auth login or a classic personal access token. Write access to the repository you are attaching to is required for image uploading.

上传使用 gh 已有的常见令牌类型进行身份验证,包括 gh auth login 生成的 OAuth 令牌或经典个人访问令牌。上传图片需要对正在附加到的仓库具有写入权限。

--attach is generally available to all users on GitHub across all plans, with no preview period. Size limits match the web upload flow: 10 MB for images and GIFs, 10 MB for video on Free plans, and 100 MB for video on paid plans. GitHub Enterprise Server is not supported in this release.

--attach 面向 GitHub 所有计划的所有用户全面开放,无预览期。大小限制与网页上传流程一致:图片和 GIF 为 10 MB,免费计划的视频为 10 MB,付费计划的视频为 100 MB。本次发布不支持 GitHub Enterprise Server。

Getting started

入门指南

Update gh to v2.99.0, then run gh issue comment --attach ./screenshot.png. --attach works the same way on gh issue and gh pr create, edit, and comment. Run gh help for the full flag reference.

将 gh 更新至 v2.99.0,然后运行 gh issue comment --attach ./screenshot.png。--attach 在 gh issue 和 gh pr 的 create、edit 和 comment 命令中以相同方式工作。运行 gh help 获取完整的标志参考。

Join the discussion on the GitHub Community and read the docs to learn more about attaching files from the command line.

加入 GitHub 社区的讨论,并阅读文档以了解如何从命令行附加文件。

Editor’s note (September 1, 2026): Updated the doc link.

编辑注记(2026年9月1日):更新了文档链接。

The post GitHub CLI: Media in issues, pull requests, and comments appeared first on The GitHub Blog.

本文《GitHub CLI:在议题、拉取请求和评论中使用媒体》首发于 GitHub 博客。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

另一事件,读法相近