2012-05-26 32 views
365

我試圖運行brew update,我得到一個關於我的本地更改的錯誤將丟失,如果我合併。我嘗試了一下我的本地變化(不記得做任何事情,但已經過去了一段時間),這使事情變得更糟。brew更新:以下未跟蹤的工作樹文件將被覆蓋合併:

下面是輸出:

MBP:Library User$ sudo brew update 
error: The following untracked working tree files would be overwritten by merge: 
    Library/Aliases/fastcgi 
    Library/Aliases/htop 
    Library/Aliases/nodejs 
    Library/Aliases/ocio 
    Library/Aliases/oiio 
    Library/Aliases/pgrep 
    Library/Aliases/pkill 
    Library/Contributions/cmds/brew-beer.rb 
    Library/Contributions/cmds/brew-dirty.rb 
    Library/Contributions/cmds/brew-graph 
    Library/Contributions/cmds/brew-grep 
    Library/Contributions/cmds/brew-leaves.rb 
    Library/Contributions/cmds/brew-linkapps.rb 
    Library/Contributions/cmds/brew-man 
    Library/Contributions/cmds/brew-mirror-check.rb 
    Library/Contributions/cmds/brew-missing.rb 
    Library/Contributions/cmds/brew-pull.rb 
    Library/Contributions/cmds/brew-readall.rb 
    Library/Contributions/cmds/brew-server 
    Library/Contributions/cmds/brew-services.rb 
    Library/Contributions/cmds/brew-switch.rb 
    Library/Contributions/cmds/brew-test-bot.commit.html.erb 
    Library/Contributions/cmds/brew-test-bot.css 
    Library/Contributions/cmds/brew-test-bot.index.html.erb 
    Library/Contributions/cmds/brew-test-bot.rb 
    Library/Contributions/cmds/brew-tests.rb 
    Library/Contributions/cmds/brew-unpack.rb 
    Library/Contributions/cmds/brew-which.rb 
    Library/Contributions/install_homebrew.rb 
    Library/Formula/abcl.rb 
    Library/Formula/abyss.rb 
    Library/Formula/akka.rb 
    Library/Formula/apollo.rb 
    Library/Formula/appledoc.rb 
    Library/Formula/arangodb.rb 
    Library/Formula/autoconf.rb 
    Library/Formula/automake.rb 
    Library/Formula/avidemux.rb 
    Library/Formula/bind.rb 
    Library/Formula/bsdconv.rb 
    Library/Formula/bsdmake.rb 
    Library/Formula/camellia.rb 
    Library/Formula/cbmbasic.rb 
    Library/Formula/cdo.rb 
    Library/Formula/checkstyle.rb 
    Library/Formula/cifer.rb 
    Library/Formula/clhep.rb 
    Library/Formula/collada-dom.rb 
    Library/Formula/crash.rb 
    Library/Formula/crossroads.rb 
    Library/Formula/css-crush.rb 
    Library/Formula/curlftpfs.rb 
    Library/Formula/dart.rb 
    Library/Formula/dasm.rb 
    Library/Formula/dfc.rb 
    Library/Formula/di.rb 
    Library/Formula/dsniff.rb 
    Library/Formula/dupx.rb 
    Library/Formula/dwatch.rb 
    Library/Formula/eprover.rb 
    Library/Formula/ext2fuse.rb 
    Library/Formula/ezlupdate.rb 
    Library/Formula/f3.rb 
    Library/Formula/fastx_toolkit.rb 
    Library/Formula/fceux.rb 
    Library/Formula/findbugs.rb 
    Library/Formula/freerdp.rb 
    Library/Formula/funcoeszz.rb 
    Library/Formula/fwknop.rb 
    Library/Formula/gabedit.rb 
    Library/Formula/gbdfed.rb 
    Library/Formula/gconf.rb 
    Library/Formula/git-encrypt.rb 
    Library/Formula/glm.rb 
    Library/Formula/gmap-gsnap.rb 
    Library/Formula/gnu-arch.rb 
    Library/Formula/gnunet.rb 
    Library/Formula/gobby.rb 
    Library/Formula/gptfdisk.rb 
    Library/Formula/griffon.rb 
    Library/Formula/grok.rb 
    Library/Formula/gtk-chtheme.rb 
    Library/Formula/gtkglextmm.rb 
    Library/Formula/gtmess.rb 
    Library/Formula/hg-flow.rb 
    Library/Formula/hqx.rb 
    Library/Formula/htop-osx.rb 
    Library/Formula/htpdate.rb 
    Library/Formula/imap-uw.rb 
    Library/Formula/iozone.rb 
    Library/Formula/ipbt.rb 
    Library/Formula/ipe.rb 
    Library/Formula/ispc.rb 
    Library/Formula/ispell.rb 
    Library/Formula/jigdo.rb 
    Library/Formula/jing.rb 
    Library/Formula/jless.rb 
    Library/Formula/jpeginfo.rb 
    Library/Formula/konoha.rb 
    Library/Formula/legit.rb 
    Library/Formula/libcouchbase.rb 
    Library/Formula/libcuefile.rb 
    Library/Formula/libextractor.rb 
    Library/Formula/libglademm.rb 
    Library/Formula/libgtextutils.rb 
    Library/Formula/libinfinity.rb 
    Library/Formula/libkate.rb 
    Library/Formula/libqalculate.rb 
    Library/Formula/libqglviewer.rb 
    Library/Formula/libreplaygain.rb 
    Library/Formula/libtool.rb 
    Library/Formula/libvbucket.rb 
    Library/Formula/libvo-aacenc.rb 
    Library/Formula/libxmi.rb 
    Library/Formula/lifelines.rb 
    Library/Formula/makeicns.rb 
    Library/Formula/mathgl.rb 
    Library/Formula/meld.rb 
    Library/Formula/mesalib-glw.rb 
    Library/Formula/minisat.rb 
    Library/Formula/minuit2.rb 
    Library/Formula/mobile-shell.rb 
    Library/Formula/movgrab.rb 
    Library/Formula/mp3cat.rb 
    Library/Formula/mpich2.rb 
    Library/Formula/mrfast.rb 
    Library/Formula/musepack.rb 
    Library/Formula/ndiff.rb 
    Library/Formula/net6.rb 
    Library/Formula/nrpe.rb 
    Library/Formula/nuttcp.rb 
    Library/Formula/oath-toolkit. 
Updating aa07533..3f070ef 
Aborting 
Error: Failed while executing git pull origin refs/heads/master:refs/remotes/origin/master 

回答

737

不要忘記取得原產地!

$ cd /usr/local
$○一二三二五三二四四五一三八三八五一四三二一○
$ git reset --hard origin/master

說明,對於那些有興趣:

什麼情況是,你要更新沖泡,但釀造本身或者是不是最新的(可能),通過某些操作系統更新(也可能)更改權限,或者brew稍微損壞(不太可能)。由於brew本身就是一個git倉庫,所以你必須將brew更新或重置爲主分支版本。 BREW [默認]位於/usr/local文件夾,所以你

  1. 轉到該文件夾​​[第一個命令]這也應該更新權限(如果不是見下文)
  2. 取起源[第二個命令]其中意味着更新您的本地版本的遠程分支brew
  3. 基於遠程主分支(也使用您當前的權限)的硬重置[第3命令]。

您也可以chown,如果你是在非須藤或管理員的個人資料
$ sudo chown -R `whoami` /usr/local
$ cd /usr/local
$ git reset --hard origin/master

要了解git的復位的第一個命令,看看this article

+3

在重置工作之前,我必須'git fetch origin'。謝謝。有趣的是,如何在過去一天添加這個答案,幸運的是我! – ghoppe

+2

'/ usr/local' 'git fetch origin' '致命的:'origin'似乎不是git存儲庫' '致命的:遠程端意外掛掉了' –

+0

@RichBradshaw'origin'是指'遠程'回購。你的問題似乎是一個連接問題(與使用GHub不同),引用錯誤(你的url不好),或者你可能指向錯誤的回購,也許是不同的類型(即SVN) –

107

我有一個類似的問題,幾個星期前,要更新舊的自制軟件安裝。這樣做:

git reset --hard origin/master 

/usr/local固定對我來說。

看來其他人也有這個問題。你有沒有看過任何建議的解決方法here

+0

像冠軍一樣工作。感謝您的鏈接! –

+0

對其他人的提示:請嘗試運行'git fetch origin',正如其他答案中所建議的一樣 - 只有這樣做才能爲我解決這個問題(沒有'git fetch origin'沒有明顯的問題,除了brew沒有看到任何更新; ))。 – Gilead

+0

今天早上我剛碰到這個釀造錯誤。有一點Google搜索引導我到這裏。這個答案完全解決了我的問題。謝謝! – memoht

11

我加入我個人的經驗,因爲它似乎比在2012年提出什麼更安全一點:

  1. 運行brew doctor
  2. 如果您收到以下警告:

    Warning: The /usr/local directory is not writable. 
    

    運行:

    sudo chown -R `whoami` /usr/local 
    

    修復權限問題(由克里斯·弗裏西納建議也)。最後再次運行brew doctor以確保您的警告消失。現在

  3. ,你應該有一個

    Warning: You have uncommitted modifications to Homebrew 
    

    可以通過貝

    cd /usr/local/Library && git stash && git clean -d -f 
    

    解決了Dr.Brew自己的建議。該命令存儲未提交的修改,以便在需要時可以返回並恢復它們。它對我來說似乎比git reset --hard origin/master更安全。

  4. 如果您願意,請檢查the official troubleshooting guide如果這裏和其他SO用戶建議的步驟無法解決您的問題。

+0

cd/usr/local/Library && git stash && git clean -d -f 然後brew更新爲我固定 – at0mzk

0

類似的答案,但如果你有不再跟蹤文件,你需要額外的步驟,從/usr/local運行

git fetch origin 
git clean -f 
git reset --hard origin/master 
0

這種方法可能比一些簡單。它涉及:

  • 修復git問題,以便您可以再次委派管理更改。
  • 無法手動移動文件或目錄。
  • 無需手動調整文件或目錄權限。

步驟(與筆記對於那些誰想要解釋):

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 

概述:
從我可以告訴,這個問題的真正原因是在回購URL的變化。現在是brew,並且是brew.git。 (完整最新網址:https://github.com/Homebrew/brew

注意1:該第一條命令將您從文件結構中的任意位置帶到正確的目錄。我的目錄結構與其他人在上面顯示的不同(Mac OS 10.11.16)不同,但使用此命令時,這些差異應該沒有關係。

注2:第二個命令將正確的遠程URL添加到新的別名;我這樣做是爲了防止這種方法達不到我想要的效果,而且我需要再次使用以前的地址。由於新的遠程工作,我會邀請其他人發表評論,簡單地改變原來的別名。我會很樂意更新答案,以反映對你有用的東西。注意3:這個第四個命令具有所需的結果:它報告了大量的更新,包括「==> Migrated HOMEBREW_REPOSITORY到/ usr/local/Homebrew!」的特別好的報告。 (強調他們的)。

相關問題