为什么切换分支时Git不删除一些文件? [英] Why doesn't Git remove some files when I switch a branch?
问题描述
最终发生的事情是该插件的文件保留在项目目录中。我想知道这是否是正常行为。为了在分支机构之间进行无缝切换,我需要做些什么?
git不会从工作中删除未跟踪的文件复制,所以除非你添加了插件的文件并在新的分支上创建了一个提交,否则git不会对你的插件文件做任何事情。如果你想删除未跟踪文件从你的工作树上,使用 git clean
- 小心,它会从磁盘中删除任何未跟踪的文件,并且无法从中恢复(不使用反删除软件)。
I have had this happen to me often. I am working on a master branch and I need to test a plugin, so I create a new branch and check it out. I download the plugin into the project directory and test it out. Then I switch back to the master branch and delete the branch I had created.
What ends up happening is the files of the plugin remain in the project directory. I'm wondering if this is normal behavior. What do I have to do in order to have a seamless switch between branches?
git will not remove untracked files from your working copy, so unless you added the files of the plugin and created a commit on the new branch git will not do anything to your plugin files.
if you want to remove untracked file from your working tree, use git clean
– be careful, it will remove any untracked file from disk and there's no way to recover from that (without using undelete software)
这篇关于为什么切换分支时Git不删除一些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!