开发者

How do I ignore everything except a couple files in the top-level directory and everything in a few directories with .gitignore

开发者 https://www.devze.com 2023-01-05 08:06 出处:网络
I want to ignore everything except a couple files in the top-level directory and everything in a few directories with .gitignore

I want to ignore everything except a couple files in the top-level directory and everything in a few directories with .gitignore

My top level .gitignore is:

*

!/app/

!gbase.php

!list-secret-prices.php

The problem is t开发者_JAVA百科hat I have to put a .gitignore with one entry of:

!*

in each of the subdirectories that I want to include for it to work. I don't want to have to put a .gitignore in everyone of the directories that I want included. I want to handle everything in the top level .gitignore.


In your case the following might be more appropriate:

/*
!app/
!gbase.php
!list-secret-prices.php

The first line ignores all top-level directories and files. Anything inside the ignored directories will also be ignored by git, even if it's not explicitly specified.

The second line unignores the app directory. It will also cause git to find all its files and subdirectories (recursively), because we never told git to ignore anything below the top-level.


I make global exclusions in my gitconfig file ($HOME/.gitconfig)

[core] excludesfile = /Users/meself/.gitignore

And then write my patterns in ~/.gitignore.

Would this help?

0

精彩评论

暂无评论...
验证码 换一张
取 消