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

后端 未结 12 798
旧巷少年郎
旧巷少年郎 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:45

    This approach may be simpler than some. It involves:

    • fixing a git issue so you can delegate management of changes to it again.
    • no manual moves of files or directories.
    • no manual adjustments of file or directory permissions.

    Steps (with notes for those who want explanations):

    cd $(brew --repository)                              // see Note 1 below
    git remote add brew https://github.com/Homebrew/brew // see Note 2 below
    git pull brew master                                 // promising fast-forward report!
    brew update                                          // see Note 3 below 
    

    Overview:
    From what I can tell, the actual cause of this issue is a change in the repo url. It's now brew and was brew.git. (Full up-to-date url: https://github.com/Homebrew/brew)

    Note 1: This first command takes you from anywhere in your file structure to the correct directory. The directory structure is different for me than what others show above (Mac OS 10.11.16), but with this command, those differences should not matter.

    Note 2: This second command adds the correct remote url to a new alias; I did so just in case this approach didn't accomplish what I wanted and I needed the previous address again. Since the new remote worked, I'll invite someone else to comment on simply changing the url aliased by origin. I'll happily update the answer to reflect what worked for you.

    Note 3: This forth command has exactly the desired result: it reports a large number of updates, including the particularly nice report of "==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!" (emphasis theirs).

提交回复
热议问题