[英]Unable to ignore directory using gitignore
Below is my directory structure. 下面是我的目录结构。
parent_directory
|--.gitignore
|--static/
| |--js/
| | |--encoding.js
| |--css
| |--parent.css
|--tools/
| |--static/
| | |--js/
| | |--css/
| |--templates/
I want to ignore outer static directory. 我想忽略外部静态目录。 I tries
static/**/
, static/
, static/**
but nothing is working. 我尝试使用
static/**/
, static/
, static/**
但是没有任何反应。 Whenever I edit encoding.js
file it appears in tracked file list. 每当我编辑
encoding.js
文件时,它就会出现在跟踪的文件列表中。
Steps I followed - 1. Edited the .gitignore file and added pattern [all three one at a time] 我遵循的步骤-1.编辑.gitignore文件并添加模式(一次全部三个)
2. Edited the file encoding.js 2.编辑文件encoding.js
3. checked git status. 3.检查git状态。 File appeared in tracked file zone.
文件出现在跟踪的文件区域中。
How should I add the pattern so that any folder or file in ./static/
folder is not tracked. 我应该如何添加模式,以便不跟踪
./static/
文件夹中的任何文件夹或文件。
Update 1: Added static in the .gitignore file. 更新1:在.gitignore文件中添加了static。 Still not working.
还是行不通。 See the attached image.
参见所附图片。 [ Solved ]
[ 解决 ]
Update 2: adding static in .gitignore file ignores the /tools/static/ directory as well which is not suppose to happen. 更新2:在.gitignore文件中添加static也会忽略/ tools / static /目录,这不会发生。 Just the outer static directory should be ignored.
仅外部静态目录应该被忽略。
You need to add static
to your .gitignore file. 您需要向.gitignore文件添加
static
。
The forward slash is stopping git from finding the directory. 正斜杠阻止git查找目录。
Edit 1: You may need to run git rm --cached static
if the folder is already being tracked by git. 编辑1:如果
git rm --cached static
已经跟踪了文件夹,则可能需要运行git rm --cached static
。
Edit 2: The poster's criteria have changed and they only want to ignore the static
folder in the root directory. 编辑2:海报上的标准已经改变,他们只是想忽略
static
根目录文件夹中。
Just add /static
to your .gitignore file (and remove static
) . 只需将
/static
添加到您的.gitignore文件中(并删除static
) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.