简体   繁体   English

Git:删除.gitignore文件后忽略文件

[英]Git: ignoring files after deleting .gitignore file

I had a magento setup in which I created a .gitignore file which is like as follows: 我有一个magento设置,其中创建了一个.gitignore文件,如下所示:

########   MAGENTO RELATED FILES AND FOLDERS    ######
var/*
media/*
app/etc/local.xml
minified/css/*
minified/css_secure/*
minified/js/*
minified/media/*

later I figured out that due to this rule var and media dirs also got ignored and were not part of commit. 后来我发现由于这个规则, varmedia dirs也被忽略了,并且不是提交的一部分。 So I tried to comment var/* and media/* lines, I tried to delete, the .gitignore file, committed and pushed to remote repo. 所以我尝试注释var/*media/*行,尝试删除.gitignore文件,提交并推送到远程仓库。 but nothing works. 但没有任何效果。

Any chance to get them back under tracking? 有机会让他们回到追踪状态吗? Please note there is only one .gitignore file. 请注意,只有一个.gitignore文件。

Many thanks!! 非常感谢!!

git tracks content; git跟踪内容; directories are not content, they are structure. 目录不是内容,而是结构。 What you can do is, drop empty placeholder files in var/ and media/ and track those. 您可以做的是,在var/media/放置空的占位符文件并进行跟踪。 That will bring the directory structure under git's supervision. 这将把目录结构置于git的监督之下。

You can keep the var/* and media/* lines in your .gitignore, just add an exception for the placeholder files like 您可以将var/*media/*行保留在.gitignore中,只需为占位符文件添加一个例外,例如

!var/README.md
!media/README.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM