Git提示Please move or remove them before you switch branches.

1,365 阅读1分钟

背景:由于是两个电脑开发,一台电脑项目已完善并提交,另一台电脑还有未提交的代码,干脆删除项目,从新到远程拉取,再进行新功能增加 本地文件夹都删了,包括.git 文件 唯独没删除项目文件夹和.idea文件夹 git init ---初始化.git 文件夹 git remote add origin https:xxxx 添加远程仓库 git fetch ---拉取远程分支 git checkout shopping

**提示 ** error: The following untracked working tree files would be overwritten by checko ut: .idea/.gitignore .idea/ReactShopping.iml .idea/misc.xml .idea/modules.xml .idea/vcs.xml Please move or remove them before you switch branches. Aborting

这句话的意思是: 以下文件未跟踪的工作树文件将被签出覆盖,在切换分支的时候你需要干掉它们

$ git clean -df ./* Removing .idea/

image.png 一次性干掉所有临时文件,再切换正常了。 当然你也可以一个一个干掉,像这样。 git clean -df ./idea/.gitignore

再切换分支正常了!! git pull 拉取项目

image.png