Ignoring a directory chain in git?

I need to ignore the following.

In paths like /a/b/c/d/e/f/g, I need to ignore /d/e/f/g. I also need to be able to ignore every place /d/e/f/g appears beneath a. I tried d/e/f/g, but that did not work. Thoughts?

  • Git porcelain command to revert a single file to its HEAD state but keep its staged state?
  • Git - Bitbucket repo hasnt stored the files in a sub-folder
  • Efficient storage of binary files in a git repository
  • How to get diff between all files inside 2 folders that are on the web?
  • What does it mean if some files in TortoiseSVN are marked “deleted” and others “deleted (+)” with a plus sign?
  • Why Subversion skips files which contain the @ symbol?
  • git svn clone not checking out all directories
  • Git credential helper causes “repository not found” error?
  • Git merge strategy 'theirs' is not resolving modify/delete conflict
  • Visual Studio Online scheduled build can't find my branch
  • When exactly does git prune objects: why is “git gc” not removing commits?
  • Removing untracked files
  • 2 Solutions collect form web for “Ignoring a directory chain in git?”





    Interesting requirement. I’m curious what your use case actually is.

    The way you should do something like this is a separate .gitignore in the parent directory of each sub-tree you need to exclude (git reads all the .gitignore files on its way down the tree).

    If you really want a single .gitignore file… Well, I haven’t tried this, but going by the gitignore doc, it’s mostly a typical shell glob, so what might work is something like:


    … repeating with an ever-increasing number of asterisks out to the deepest you expect it to reasonably go.

    I imagine there will be a performance penalty here, but I don’t know how serious. Probably not noticeable for most repos on any system built in the last 5-10 years.

    Git Baby is a git and github fan, let's start git clone.