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

简介: 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
目录
相关文章
|
5月前
|
开发工具 git
git checkout (branchname
git checkout (branchname) 是 Git 中切换分支的一种命令。通过这个命令,你可以将当前工作目录切换到指定的分支上。branchname 参数是可选的,如果不指定,则默认切换到主分支(master 或 main)。
97 2
|
5天前
|
开发工具 git 索引
$ git revert -m v1.0.21 6003eb5f5b455f0a3dfb74f48f63878e7 error: option `mainline' expect
$ git revert -m v1.0.21 6003eb5f5b455f0a3dfb74f48f63878e7 error: option `mainline' expect
|
5月前
|
开发工具 git 开发者
|
5月前
|
开发工具 git
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
|
4月前
|
开发工具 git
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
66 1
|
4月前
|
开发工具 git
git error 已解决【Another git process seems to be running in this repository, e.g. an editor opened by】
git error 已解决【Another git process seems to be running in this repository, e.g. an editor opened by】
54 2
|
5月前
|
网络安全 开发工具 git
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
69 0
|
4月前
|
开发工具 git
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
226 1
|
5月前
|
缓存 开发工具 git
Git Cloning into :error: RPC failed
Git Cloning into :error: RPC failed
73 0
|
5月前
|
开发工具 git
Git:error: remote origin already exists
Git:error: remote origin already exists
53 2