git报错:error: Your local changes to the following files would be overwritten by checkout:
生活随笔
收集整理的這篇文章主要介紹了
git报错:error: Your local changes to the following files would be overwritten by checkout:
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原因
原本想切換到dev分支,拉取遠程dev分支,但我將分支上的數據修改了,此時切換分支報錯
解決方案
方法一: 存到暫存區
# 暫存
git add .
git stash
之后切換分支到dev,執行git pull,切換回原分支,獲取之前修改的文件,使用如下命令
// 取出的時候使用
git stash pop
方法二:發起一個commit 存到提交歷史
git add .
git commit -m "commit message"
不太建議的方案
以下兩種方案我沒有嘗試過,但是忽視錯誤,在開發中時不可取的行為,所以不建議使用
方法一:刪除修改
git clean -n //這個是清除文件預覽
git clean -f //強制清除文件
方法二:強制切換
git checkout -f <branch> // <branch>為要切換到的分支名,注意不帶“<>”
總結
以上是生活随笔為你收集整理的git报错:error: Your local changes to the following files would be overwritten by checkout:的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(三十)es6的一些问题(笔记)
- 下一篇: 自学一周python做的一个小游戏《大球