为什么git要删除我的脚本文件夹?
我刚刚更新了.gitignore文件,使其不包含节点和bower模块文件为什么git要删除我的脚本文件夹?,git,gitignore,Git,Gitignore,我刚刚更新了.gitignore文件,使其不包含节点和bower模块文件 node_modules/ .tmp .sass-cache sample/bower_components/ sample/node_modules/ sample/images/ 但是当我运行gitclean-f时,我的终端以 Removing sample/scripts 当然,sample/scripts是我希望保留在项目中的文件夹,我没有在.gitignore中指定它,所以为什么要删除它??我假设您没有将任何
node_modules/
.tmp
.sass-cache
sample/bower_components/
sample/node_modules/
sample/images/
但是当我运行gitclean-f时,我的终端以
Removing sample/scripts
当然,
sample/scripts
是我希望保留在项目中的文件夹,我没有在.gitignore中指定它,所以为什么要删除它??我假设您没有将任何文件从sample/scripts
目录添加到Git存储库。这意味着它们不会被跟踪,并且将从手册中删除:从当前目录开始,通过递归删除不受版本控制的文件来清理工作树。
您可以通过以下方式检查本地存储库正在跟踪哪些文件:
git ls-tree --full-tree -r HEAD
如果缺少文件,只需添加它们:
git add sample/scripts/.
git commit -m "Add missing sample scripts"
git clean -f
Git只跟踪文件,所以空目录不算。您可以添加基本的.gitignore来修复此问题:
touch sample/scripts/.gitignore
git add sample/scripts/.gitignore
git commit -m "Add sample scripts gitignore"
git clean -f
我假设您没有将
sample/scripts
目录中的任何文件添加到Git存储库中。这意味着它们不会被跟踪,并且将从手册中删除:从当前目录开始,通过递归删除不受版本控制的文件来清理工作树。
您可以通过以下方式检查本地存储库正在跟踪哪些文件:
git ls-tree --full-tree -r HEAD
如果缺少文件,只需添加它们:
git add sample/scripts/.
git commit -m "Add missing sample scripts"
git clean -f
Git只跟踪文件,所以空目录不算。您可以添加基本的.gitignore来修复此问题:
touch sample/scripts/.gitignore
git add sample/scripts/.gitignore
git commit -m "Add sample scripts gitignore"
git clean -f
将删除Git不知道的文件。如果不传递-x
标志,它将删除未跟踪且未明确忽略的文件
因此,如果删除了sample/scripts
,那么Git显然不会跟踪它。如果您想保留它,您必须通过添加和提交它来跟踪它,或者将它添加到.gitignore
中
顺便说一句,最好先运行git clean-n
,看看git会删除什么,然后再实际删除。会删除git不知道的文件。如果不传递-x
标志,它将删除未跟踪且未明确忽略的文件
因此,如果删除了sample/scripts
,那么Git显然不会跟踪它。如果您想保留它,您必须通过添加和提交它来跟踪它,或者将它添加到.gitignore
中
顺便说一句,最好先运行
git clean-n
,看看git在实际运行之前会删除什么。问一个明显的问题,是否已经将sample/scripts
添加到git repo中?因为sample/scripts
不受版本控制?它是一个空目录吗?问一个显而易见的问题,sample/scripts
是否已经添加到git repo中?因为sample/scripts
不受版本控制?它是一个空目录吗?