git checkout命令报错Your local changes to the following files would be overwritten by checkout
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
在linux下使用命令
git checkout master
出现错误
error:Your local changes to the following files would be overwritten by checkout
Please commit your changes or stash them before you switch branches.
错误原因:
根据提示信息,当前分支有未跟踪的文件,checkout 命令会覆盖它们,请缓存( stash )或者提交( commit )
解决方法
根据需要做出相应的操作即可。
1.保存修改
//第一种方式 存到暂存区
git add.
git stash
//取出的时候使用
git stash pop
//第二种方式 发起一个commit 存到提交历史
git add.
git commit -m "commit message"
如果想直接保存,可以选用第二种方式。
2.放弃修改
//第一种方式 清除未跟踪文件
git clean n //这个是清除文件预览
git clean -f //强制清除文件
//第二种方式 强制切换分支
git checkout -f master
//这里master是我要转换的分支名称,可替换成自己需要的分支名称
推荐使用第一种方式,第二种可能会造成文件修改丢失。
参考文章:Git-命令行-拯救“Your local changes to the following files would be overwritten by checkout”




A beautiful web dashboard for Linux
最近提交(Master分支:5 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
所有评论(0)