Git - Error:The following untracked working tree files would be overwritten by checkout

Posted 放羊的牧码

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git - Error:The following untracked working tree files would be overwritten by checkout相关的知识,希望对你有一定的参考价值。

在IDEA中进行分支切换时,出现如此错误,导致无法正常切换:error: The following untracked working tree files would be overwritten by checkout

通过错误提示可知,是由于一些untracked working tree files引起的问题。所以只要解决了这些untracked的文件就能解决这个问题。

解决方式

打开SourceTree通过命令行,进入本地版本仓库目录下,直接执行即可。可能很多人都不明白-d,-fx到底是啥意思,其实git clean -d -fx表示:删除一些没有 git add 的文件。

git clean -d -fx

git clean 参数

  • -n 显示将要删除的文件和目录;
  • -x -----删除忽略文件已经对git来说不识别的文件
  • -d -----删除未被添加到git的路径中的文件
  • -f -----强制运行
  • git clean -n
  • git clean -df
  • git clean -f

以上是关于Git - Error:The following untracked working tree files would be overwritten by checkout的主要内容,如果未能解决你的问题,请参考以下文章

git发生冲突:error: Your local changes to the following files would be overwritten by merge

Git - Error:The following untracked working tree files would be overwritten by checkout

git pull error: Your local changes to the following files would be overwritten by merge

git pull error: Your local changes to the following files would be overwritten by merge

git pull 报错 error: Your local changes to the following files would be overwritten by merge

git pull遇到错误:error: Your local changes to the following files would be overwritten by merge: