Brew update failed: untracked working tree files would be overwritten by merge

后端 未结 12 802
旧巷少年郎
旧巷少年郎 2020-12-12 09:03

Trying to update Homebrew with brew update I got the following error

error: The following untracked working tree files would be overwrittenby me         


        
12条回答
  •  爱一瞬间的悲伤
    2020-12-12 09:23

    You need to do the following:

    cd $(brew --prefix)
    rm Library/Formula/argp-standalone.rb
    rm Library/Formula/cocot.rb
    

    And then do the

    git fetch origin
    git reset --hard origin/master
    brew update
    

    Basically, to explain a bit more:

    cd $(brew --prefix)
    

    tells cd to change the directory to whatever brew --prefix will output. If you try executing brew --prefix command you should see something in lines of:

    brew --prefix
    /usr/local
    

    So the command would be in this case an equivalent of cd /usr/local. Newer brew versions have formulae under its installation prefix and Library/Formula/, so that's where you need to look for those outdated/changed files.

    Note, that if you changed those formulae yourself for a particular reason (like pinning a version) this action will revert them back to default ones and may produce unwanted effects.

    @TedPennings noted in comments that this worked for him, but his sequence was:

    1. chown everything to my_username:admin, ie, sudo chown -R ted:admin $(brew --prefix)
    2. run the two git commands above,git fetch origin and git reset --hard origin/master

提交回复
热议问题