git项目可以跟踪全局gitignore中列出的目录吗? [英] Can a git project track a directory listed in my global gitignore?

查看:80
本文介绍了git项目可以跟踪全局gitignore中列出的目录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个需要跟踪其node_modules目录的项目.我真的不想删除对该目录的全局gitignore引用,因为所有其他项目都应该跟踪node_modules目录.

I'm working on a project that needs to track it's node_modules directory. I don't really want to remove my global gitignore reference to that directory because all other projects should not be tracking the node_modules directory.

是否有一种方法可以强制git在项目级别跟踪某些内容?还是我需要遍历所有项目,以验证每个项目都有自己的忽略项,然后从我的全局gitignore中删除引用?

Is there a way to force git to track something at the project level? Or do I need to go through all projects verifying each has it's own ignore and then remove the reference from me global gitignore?

推荐答案

是的,您可以向本地.gitignore添加一个否定项,以使git仅针对该项目对其进行跟踪.

Yes, you can add a negation to a local .gitignore to make git track it only for this project.

!node_modules

这篇关于git项目可以跟踪全局gitignore中列出的目录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆