配置git只跟踪一个文件扩展名 [英] Configure git to track only one file extension

查看:370
本文介绍了配置git只跟踪一个文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多不同文件的目录树。父目录上有300个目录。每个目录都可以有其他子目录。



我只想跟踪所有子目录中的* .cocci。这是我的.gitignore:

  * 
!*。cocci

但它不起作用,因为子目录上的文件没有被跟踪。我怎么能告诉git,我只想跟踪所有子目录中的* .cocci? 解决方案

阅读这个问题



你想要:

 #黑名单一切
*
#将所有目录白名单
!* /
#将您感兴趣的文件列入白名单
!*。cocci

请注意,这只会追踪 *。cocci 档案。您的行为不起作用,因为您忽略所有内容(这是第一行),忽略所有子目录。

I have one directory tree with many kind of different files. There are 300 directories on the parent directory. Each directory could have other sub directories.

I only want to track *.cocci on all sub directories. Here is my .gitignore:

*
!*.cocci

But it do not work, as the files on sub directories are not tracked. How can I tell git that I only want to track *.cocci on all sub directories?

解决方案

Read this question.

You want:

# Blacklist everything
*
# Whitelist all directories
!*/
# Whitelist the file you're interested in. 
!*.cocci 

Note, this'll track only *.cocci files. Yours doesn't work because you ignore everything (that's the first line), which ignores all subdirectories.

这篇关于配置git只跟踪一个文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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