Magit 4.6 released

Magit 4.6 released

Magit 4.6 发布

I am excited to announce the release of Magit version 4.6, consisting of 313 commits since the last release half a year ago. The release notes can be found here. 我很高兴地宣布 Magit 4.6 版本正式发布。自半年前上一个版本发布以来,该版本共包含了 313 次提交。发布说明可以在这里找到。

It’s Magit! A Git interface inside Emacs. Magit is a text-based Git user interface that puts an unmatched focus on streamlining workflows. Commands are invoked using short mnemonic key sequences that take the cursor’s position in the highly actionable interface into account to provide context-sensitive behavior. With Magit you can do nearly everything that you can do when using Git on the command-line, but at greater speed and while taking advantage of advanced features that previously seemed too daunting to use on a daily basis. Many users will find that by using Magit they can become more effective Git user. For more information about Magit, see https://magit.vc and these blog posts. Please consider sponsoring my work. Thank you! — Jonas Bernoulli 这就是 Magit!一个运行在 Emacs 内部的 Git 界面。Magit 是一个基于文本的 Git 用户界面,它极其专注于简化工作流程。通过简短且易记的按键序列即可调用命令,这些命令会根据光标在高度交互界面中的位置,提供上下文相关的操作。使用 Magit,你几乎可以完成命令行 Git 能做的所有事情,而且速度更快,同时还能利用那些以往看起来过于复杂而难以日常使用的进阶功能。许多用户会发现,使用 Magit 可以让他们成为更高效的 Git 用户。欲了解更多关于 Magit 的信息,请访问 https://magit.vc 以及这些博客文章。请考虑赞助我的工作。谢谢!—— Jonas Bernoulli

Blob improvements

Blob(数据对象)改进

The primary focus of this release are blob-visiting buffers. For now the hope is that most users will find working with such buffers slightly more pleasant, without necessarily becoming aware that anything changed. The goal was to pay off technical debt and to prepare for future changes. 本次发布的主要重点是访问 blob 的缓冲区。目前希望大多数用户在使用这些缓冲区时会感到稍微顺手一些,而不必察觉到具体发生了什么变化。其目标是偿还技术债务并为未来的变更做准备。

Visiting blobs now always involves magit-find-file-noselect, even when an existing buffer may be involved. The behavior of this function is getting closer to that of find-file-noselect. Implemented support for visiting blobs for the benefit of features such as syntax-highlighting, as opposed to the user visiting it explicitly. Such “volatile” blob buffers are hidden and are cached for a while, in case they are needed again. If the user visits a hidden cached blob, the buffer is renamed to reveal it, and it is no longer subject to garbage collection. 现在访问 blob 总是会调用 magit-find-file-noselect,即使涉及现有缓冲区也是如此。该函数的行为正变得越来越接近 find-file-noselect。实现了对访问 blob 的支持,以服务于语法高亮等功能,而不是仅限于用户显式访问。这些“易失性”的 blob 缓冲区会被隐藏并缓存一段时间,以备再次使用。如果用户访问了一个隐藏的缓存 blob,缓冲区会被重命名以显示出来,并且不再会被垃圾回收。

Blobs can now alternatively be visited with nothing but a blob object id (instead of a revision and a path). Blob-visiting buffers can now be reverted with g, which is useful when the buffer is visited via, e.g., a branch, as opposed to a revision or blob object id. The buffer is not needlessly refreshed, if the blob oid does not change. Improved support for jumping to the same location in another blob, from a buffer visiting a blob or file. 现在,访问 blob 时可以仅使用 blob 对象 ID(而无需修订版本和路径)。访问 blob 的缓冲区现在可以使用 g 进行还原,这在通过分支(而非修订版本或 blob 对象 ID)访问缓冲区时非常有用。如果 blob oid 没有改变,缓冲区就不会进行不必要的刷新。改进了从访问 blob 或文件的缓冲区跳转到另一个 blob 中相同位置的支持。

Experimental syntax highlighting in diffs

Diff 中的实验性语法高亮

Syntax highlighting can now be enabled for diffs. This is disabled by default, because the work is still being performed synchronously, which leads to noticeable delays for large diffs and can be sluggish even for smaller diffs. A future release is going to add support for asynchronous diff syntax highlighting. (The blob buffer cache added in this release does help, but is not enough.) 现在可以为 diff 启用语法高亮。默认情况下此功能是禁用的,因为目前处理过程仍是同步进行的,这会导致大型 diff 出现明显的延迟,甚至在较小的 diff 中也会感到迟钝。未来的版本将增加对异步 diff 语法高亮的支持。(本次发布中添加的 blob 缓冲区缓存确实有帮助,但还不够。)

Configure magit-diff-fontify-hunk to try out this feature now, but please just disable it again, if it turns out to still be too slow for your taste. If you enable this, you should also customize the new option magit-diff-specify-hunk-foreground and possibly the new option magit-diff-use-indicator-faces as well. 配置 magit-diff-fontify-hunk 即可立即尝试此功能,但如果发现它对你来说仍然太慢,请将其禁用。如果你启用了此功能,还应该自定义新选项 magit-diff-specify-hunk-foreground,以及可能需要自定义的新选项 magit-diff-use-indicator-faces

Improved Git hook to Elisp hook bridge

改进的 Git Hook 到 Elisp Hook 的桥接

The new Git variables hook.NAME.event and hook.NAME.command are now used to call Elisp hooks from Git hooks. After waiting for such functionality for two decades, I came to the conclusion that this will never be implemented, and finally added a noisy kludge to get the same functionality anyway, in the previous release. Of course, just one release later, Git added the missing functionality 😝. We now use Git’s variables, which means that Elisp hooks can now only be called from Git hooks when using Git v2.54.0 or greater. 新的 Git 变量 hook.NAME.eventhook.NAME.command 现在被用于从 Git hook 调用 Elisp hook。在等待了二十年之后,我得出结论认为这永远不会被实现,于是我在上一个版本中添加了一个嘈杂的补丁来实现相同的功能。当然,仅仅过了一个版本,Git 就添加了缺失的功能 😝。我们现在使用 Git 的变量,这意味着只有在使用 Git v2.54.0 或更高版本时,才能从 Git hook 调用 Elisp hook。

Improved commit message authoring

改进的提交信息编写

Added support for compiling a list of definitions that are modified in a diff, and for inserting such lists when authoring commit messages. The new commands git-commit-insert-changelog-gnu and git-commit-insert-changelog-plain insert such list and can be invoked from the same menu (on C-c C-i), which is used to insert commit trailers. When authoring commit messages, complete-symbol now completes against modified definitions and symbols appearing in modified lines. 增加了对编译 diff 中修改的定义列表的支持,并支持在编写提交信息时插入这些列表。新命令 git-commit-insert-changelog-gnugit-commit-insert-changelog-plain 可以插入此类列表,并可从用于插入提交尾注(trailers)的同一菜单(C-c C-i)中调用。在编写提交信息时,complete-symbol 现在可以针对修改后的定义以及出现在修改行中的符号进行补全。

Please consider making a donation to support my work on Magit, Transient, Forge, Package-Build, Melpa, Emacsmirror and my other packages. This is how I make a living. Thank you! — Jonas Bernoulli 请考虑捐款以支持我在 Magit、Transient、Forge、Package-Build、Melpa、Emacsmirror 以及其他软件包上的工作。这是我的谋生方式。谢谢!—— Jonas Bernoulli

Some alternative donation options are available. Comments on Reddit and Github. Posted on 1st July 2026 提供了一些其他的捐赠选项。欢迎在 Reddit 和 Github 上发表评论。发布于 2026 年 7 月 1 日。