Git:忽略文件而不是目录中的子目录 [英] Git: ignore files but not sub-directories in a directory

查看:163
本文介绍了Git:忽略文件而不是目录中的子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中的所有开发都是在某个目录深度完成的,所以我习惯于cd到二级目录并在那里写一些临时文件。这棵树看起来像这样:

$ $ $ $ $ b $ g

dev /
important_stuff /
more_stuff /
自述文件
prod /
important_stuff /
more_stuff /
自述文件
temp_1.txt
test.cc

我想要直接忽略项目中的文件/ - temp_1.txt test.cc 。我可以做到这一点吗?

解决方案

您可以执行以下操作:

<项目/ * /



项目/ *
! p>这将忽略项目但是 项目中的所有目录中的所有文件。


I have a project in which all development is done at some directory depth, and so I'm used to cd-ing to a second-level directory and write some temporary files there. The tree looks like this:

repo
    .git/
    project/
        dev/
            important_stuff/
            more_stuff/
            README
        prod/
            important_stuff/
            more_stuff/
            README
        temp_1.txt
        test.cc

I would like to git-ignore exactly files that are directly in project/ - temp_1.txt and test.cc in this case. How can I do this?

解决方案

You can do the following:

project/*
!project/*/

This will ignore all files in project but unignore all directories in project.

这篇关于Git:忽略文件而不是目录中的子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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