升級錯誤訊息
升級時如果出現以下錯誤:
error: Your local changes to the following files would be overwritten by checkout:
檔案位置
Please commit your changes or stash them before you switch branches.表示有一些自定義的修改檔案與更新檔案造成衝突,以下提供一些解法。
保存修改後再切換分支
如果想保留這些修改,可以先暫存:
git stash save "備份修改以升級 Mastodon"
git checkout 目標分支或版本 "如 4.x.x"升級後如果需要恢復修改,可以使用:
git stash pop如果這些修改需要保留,請先將它們 commit 到目前的分支,再切換分支:
git add 檔案位置
git commit -m "升級前備份修改"
git checkout 目標分支或版本 "如 4.x.x"捨棄本地修改
如果這些修改不重要,可以直接捨棄:
git reset --hard
git checkout 目標分支或版本 "如 4.x.x"又或是只捨棄被修改過的特定檔案:
git restore 檔案位置
git checkout 目標分支或版本 "如 4.x.x"選擇合適的方案之後,就可以順利切換分支進行升級。