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 6100483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:23:30+00:00 2026-05-23T13:23:30+00:00

If I put a pattern in a .gitignore file with a leading slash, does

  • 0

If I put a pattern in a .gitignore file with a leading slash, does the slash refer to the directory in which the .gitignore file is located, or does it refer to the root of the whole repository?

(The man pages I have found have hidden this information carefully.)

  • 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-23T13:23:30+00:00Added an answer on May 23, 2026 at 1:23 pm

    This is the documentation text:

    • A leading slash matches the beginning of the pathname. For example, “/*.c” matches “cat-file.c”
      but not “mozilla-sha1/sha1.c”.

    These are my guesses:

    • If you use an in-repository-.gitignore, the directory in which the .gitignore
      is located – it is not really useful to make it relative to the repository root.

      A short experiment with same-named files in the repository root and a subdirectory (and a
      .gitignore in this same directory) confirms this.

    • If you use an .git/info/exclude or core.excludesfile, I suppose it is relative
      to the repository root.

      Also this is (for info/exclude) confirmed by the same test (both tests on 1.7.3.4).

    Schnouki found the right part of the documentation about this (emphasis mine):

    • […]
    • Patterns read from a .gitignore file in the same directory as the path, or in
      any parent directory, with patterns in the higher level files (up to the toplevel
      of the work tree) being overridden by those in lower level files down to the
      directory containing the file. These patterns match relative to the location of
      the .gitignore file.
      A project normally includes such .gitignore files in its
      repository, containing patterns for files generated as part of the project build.
    • […]

    One could say that this fact could have been repeated again at the later part quoted above, for clarity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When implementing the Strategy Pattern, where does one put the code that determines which
I need to use .gitignore to exclude a directory in the root of my
Simply put, MVC is the pattern for separating contents (model) from presentation (view), and
How do I implement the singleton pattern in C#? I want to put my
Put them all in one separate folder structure or along with classes which implements
I have put my problem case below, which simplifies a real world problem I
I'm a little confused about the MVVM pattern which i'm combining with PRISM. In
i need a pattern which satisfies mysql field names, but also with the option
I am investigating WPF's MVVM design pattern. But am unsure where to put the
If the string is of the pattern XxxXyzAbc... The expected out put from sed

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.