Mac M系列 git branch 中文亂碼

Mac M系列 git branch 中文亂碼

git branc 中文名字過長(zhǎng)顯示亂碼問題

例如顯示如下

git:(feature/測(cè)試-****)

查看 git 版本 git -v

?  ~ git -v
git version 2.39.3 (Apple Git-146)

發(fā)現(xiàn)是Xcode 內(nèi)置 git版本是 2.39.x 導(dǎo)致2.40.x 已經(jīng)修復(fù)

 * sscanf(3) used in "git symbolic-ref --short" implementation found
   to be not working reliably on macOS in UTF-8 locales.  Rewrite the
   code to avoid sscanf() altogether to work it around.
   (merge 613bef56b8 jk/shorten-unambiguous-ref-wo-sscanf later to maint).

如果不想升級(jí) git 可以按照以下方式切使用 oh-my-zsh

修改 oh-my-zsh 代碼,去掉 --short 參數(shù),把symbolic-ref --short 改為 symbolic-ref主要在lib/git.zshlib/cli.zsh 更改就行

升級(jí)git 解決

brew install git
# 安裝成功后執(zhí)行
brew info git

顯示如下

==> git: stable 2.45.2 (bottled), HEAD
Distributed revision control system
https://git-scm.com
Installed
/opt/homebrew/Cellar/git/2.45.2 (1,664 files, 51.5MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-07-05 at 10:34:35
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/git.rb
License: GPL-2.0-only
==> Dependencies
Required: gettext ?, pcre2 ?
==> Options
--HEAD
  Install HEAD version
==> Caveats
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
Subversion interoperability (git-svn) is now in the `git-svn` formula.

zsh completions and functions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Analytics
install: 128,337 (30 days), 436,727 (90 days), 1,516,995 (365 days)
install-on-request: 125,830

如果想在當(dāng)前查看

exec zsh
# 然后執(zhí)行一下命令
git --version
## 版本如下
git version 2.45.2

然后就搞定了就可以全部展示出來了

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容