美文网首页
Mac M系列 git branch 中文乱码

Mac M系列 git branch 中文乱码

作者: Q14 | 来源:发表于2024-07-09 11:20 被阅读0次

    Mac M系列 git branch 中文乱码

    git branc 中文名字过长显示乱码问题

    例如显示如下

    git:(feature/测试-****)
    

    查看 git 版本 git -v

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

    发现是Xcode 内置 git版本是 2.39.x 导致2.40.x 已经修复

     * 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).
    

    如果不想升级 git 可以按照以下方式切使用 oh-my-zsh

    修改 oh-my-zsh 代码,去掉 --short 参数,把symbolic-ref --short 改为 symbolic-ref主要在lib/git.zshlib/cli.zsh 更改就行

    升级git 解决

    brew install git
    # 安装成功后执行
    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
    

    如果想在当前查看

    exec zsh
    # 然后执行一下命令
    git --version
    ## 版本如下
    git version 2.45.2
    

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

    相关文章

      网友评论

          本文标题:Mac M系列 git branch 中文乱码

          本文链接:https://www.haomeiwen.com/subject/nezacjtx.html