Homebrew-使用总结

Homebrew-使用总结

报错

  1. 执行brew update命令,报错:

    fatal: Could not resolve HEAD to a revision
    Already up-to-date.
    

    解决方法:

    1. 执行:brew update --verbose

      执行结果:

      Checking if we need to fetch /opt/homebrew...
      Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-core...
      Fetching /opt/homebrew...
      Updating /opt/homebrew...
      Branch 'master' set up to track remote branch 'master' from 'origin'.
      Switched to and reset branch 'master'
      Your branch is up to date with 'origin/master'.
      Switched to and reset branch 'stable'
      Current branch stable is up to date.
      
      Updating /opt/homebrew/Library/Taps/homebrew/homebrew-core...
      fatal: Could not resolve HEAD to a revision
      
      Already up-to-date.
      
    2. 打开报错路径:cd /opt/homebrew/Library/Taps/homebrew/homebrew-core

    3. 执行:ls -al

      执行结果:

      total 0
      drwxr-xr-x   3 hsh  admin   96 10 14 16:27 .
      drwxr-xr-x   3 hsh  admin   96 10 14 16:27 ..
      drwxr-xr-x  12 hsh  admin  384 10 15 14:12 .git
      
    4. 执行git fetch --prune origin

      执行结果:

      remote: Enumerating objects: 3, done.
      remote: Counting objects: 100% (2/2), done.
      remote: Total 3 (delta 2), reused 2 (delta 2), pack-reused 1
      Unpacking objects: 100% (3/3), 1.54 KiB | 92.00 KiB/s, done.
      From https://github.com/Homebrew/homebrew-core
       * [new branch]              update-tflint.rb-1634223541 -> origin/update-tflint.rb-1634223541
      
    5. 执行git pull --rebase origin master

      执行结果:

      From https://github.com/Homebrew/homebrew-core
       * branch                    master     -> FETCH_HEAD
      
    6. 成功后即可执行更新:brew update

      执行结果:

      Already up-to-date.
      
    7. 之后便可正常执行其他命令了

      eg:brew install rbenv ruby-build

微信公众号

扫描下方二维码关注个人微信公众号,实时获取更多干货,哈哈哈!

作者:Angelo
本文版权归作者所有,欢迎转载,但未经作者同意必须在文章页面给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/cy521/p/15410939.html