Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3667170
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:58:04+00:00 2026-05-19T01:58:04+00:00

I have a directory structure like this: root folder1 abc.json def.json somedir more.json folder2

  • 0

I have a directory structure like this:

  • root
    • folder1
      • abc.json
      • def.json
      • somedir
        • more.json
    • folder2
      • qwe.json
      • rty.json
    • spec
      • mock1.json
      • mock2.json
      • somedir
        • more_mocks.json

Now using a .gitignore I want to ignore all *.json files except for the ones in the spec. I don’t want to use a .gitignore in folder1 and folder2 because there are a ton of these and they will get added to a lot, and I’m sure I will forget to move the right .gitignore file in place.

In addition, there may be more nested directories with JSON files, and this rule needs to apply to all subdirectories as well.

So how do I ignore all files of a type, except for a certain subdirectory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:58:05+00:00Added an answer on May 19, 2026 at 1:58 am

    An optional prefix ! which negates the
    pattern; any matching file excluded by
    a previous pattern will become
    included again. If a negated pattern
    matches, this will override lower
    precedence patterns sources.

    https://git-scm.com/docs/gitignore

    *.json
    !spec/*.json
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory structure like this: - Root - Versioned deployment folder -
I have a directory structure like this Root Sub Dir A Content Admin And
I have my directory structure like this: root/ sift/ __init__.py sift_descriptors.proto sift_descriptors_pb2.py project/ __init__.py
When creating gems, I often have a directory structure like this: |--lib |-- helpers.rb
I am a beginner in SVN.I have the SVN directory structure like this: |-trunk
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have this directory structure. In my project root directory I have a main
So, I have an app/assets/stylesheets/ directory structure that looks something like this: |-dialogs |-mixins
Suppose you have a directory structure like this: A/ B/ a.1 b.2 c.3 I'm
I have the following directory structure on my Apache web root. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.