我在我的Java项目中有两个分支:主和重构。我已经完成了重构的工作,所以现在想要checkout master
并将重构合并到主模块中。在进行重构时,我还向.gitignore添加了一些文件(其中一个是.idea),现在我得到了:
[michal@michal-pc MCleaner]$ git checkout master
error: The following untracked working tree files would be overwritten by checkout:
.idea/description.html
.idea/misc.xml
.idea/modules.xml
.idea/project-template.xml
.idea/vcs.xml
Please move or remove them before you switch branches.
Aborting
我读过很多帖子,但都没有用。如何在不访问主分支的情况下删除这些文件?有办法解决这个问题吗?如果可以的话,请提供cmd命令,我仍然是git的新手。
这是git status
的输出
On branch refactor
Your branch is up-to-date with 'origin/refactor'.
Untracked files: (use "git add <file>..." to include in what will be committed)
.idea/
target/
nothing added to commit but untracked files present (use "git add" to track)
发布于 2017-01-21 22:04:32
将以下内容添加到.gitignore
.idea
并删除此目录。
git rm -r .idea
然后提交更改。
发布于 2019-02-18 01:57:19
第一轮
get checkout <branch_name>
结果如下所示
error: The following untracked working tree files would be overwritten by checkout:
.idea/codeStyles/Project.xml
.idea/codeStyles/codeStyleConfig.xml
.idea/workspace.xml
Please move or remove them before you switch branches.
Aborting
如果您可以丢失这些文件中的任何数据(,它们将被覆盖),那么继续运行
get checkout <branch_name> --force
发布于 2017-01-21 22:02:40
查看…的手册
git clean --help
https://stackoverflow.com/questions/41784993
复制相似问题