Skip to content
Fix Code Error

ignoring any ‘bin’ directory on a git project

March 13, 2021 by Code Error
Posted By: Anonymous

I have a directory structure like this:

.git/
.gitignore
main/
  ...
tools/
  ...
...

Inside main and tools, and any other directory, at any level, there can be a ‘bin’ directory, which I want to ignore (and I want to ignore everything under it too). I’ve tried each of these patterns in .gitignore but none of them work:

/**/bin/**/*
/./**/bin/**/*
./**/bin/**/*
**/bin/**/*
*/bin/**/*
bin/**/*
/**/bin/* #and the others with just * at the end too

Can anyone help me out? The first pattern (the one I think should be working) works just fine if I do this:

/main/**/bin/**/*

But I don’t want to have an entry for every top-level directory and I don’t want to have to modify .gitignore every time I add a new one.

This is on Windows using the latest msysgit.

EDIT: one more thing, there are files and directories that have the substring ‘bin’ in their names, I don’t want those to be ignored 🙂

Solution

Before version 1.8.2, ** didn’t have any special meaning in the .gitignore. As of 1.8.2 git supports ** to mean zero or more sub-directories (see release notes).

The way to ignore all directories called bin anywhere below the current level in a directory tree is with a .gitignore file with the pattern:

bin/

In the man page, there an example of ignoring a directory called foo using an analogous pattern.

Edit:
If you already have any bin folders in your git index which you no longer wish to track then you need to remove them explicitly. Git won’t stop tracking paths that are already being tracked just because they now match a new .gitignore pattern. Execute a folder remove (rm) from index only (–cached) recursivelly (-r). Command line example for root bin folder:

git rm -r --cached bin
Answered By: Anonymous

Related Articles

  • Java SSLHandshakeException "no cipher suites in common"
  • Convert array to nested JSON object - Angular Material tree
  • Git command to show which specific files are ignored…
  • Checkout another branch when there are uncommitted…
  • Why do I have to "git push --set-upstream origin "?
  • git pull while not in a git directory
  • Git - Pushing code to two remotes
  • Why do git fetch origin and git fetch : behave differently?
  • Git Using Remote Branch
  • Retrieve specific commit from a remote Git repository
  • How do I keep only the first map and when the game…
  • How do I make a Git commit in the past?
  • How to recover stashed uncommitted changes
  • Why call git branch --unset-upstream to fixup?
  • What are the real-world strengths and weaknesses of…
  • In plain English, what does "git reset" do?
  • What's the difference between HEAD^ and HEAD~ in Git?
  • What is "git remote add ..." and "git push origin master"?
  • Various ways to remove local Git changes
  • Git workflow and rebase vs merge questions
  • How do I ignore files in Subversion?
  • How do you easily create empty matrices javascript?
  • How to track untracked content?
  • ExpressJS How to structure an application?
  • How to simplify sequential logic design by…
  • Active tab issue on page load HTML
  • How to properly do JSON API GET requests and assign…
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • How can I find the location of origin/master in git,…
  • How to backup a local Git repository?
  • git lfs push to github failure on Ubuntu 18.04
  • Does "git fetch --tags" include "git fetch"?
  • Setting up and using Meld as your git difftool and mergetool
  • How to retrieve a single file from a specific…
  • What is your most productive shortcut with Vim?
  • git: How to ignore all present untracked files?
  • Git submodule update
  • How to pull in changes from skeleton sub-repository…
  • What's the difference between "git reset" and "git…
  • Is it safe to shallow clone with --depth 1, create…
  • Resync git repo with new .gitignore file
  • How to fix Git error: object file is empty?
  • Why does Git say my master branch is "already up to…
  • Backbone.js - Should nested Views maintain…
  • Git ignore file for Xcode projects
  • Git merge with force overwrite
  • How to use Git for Unity3D source control?
  • Ukkonen's suffix tree algorithm in plain English
  • Examples of GoF Design Patterns in Java's core libraries
  • Creating a custom counter in Spark based on…
  • Global Git ignore
  • Retrieve the commit log for a specific line in a file?
  • Recalculate merge conflicts (ie. how to generate…
  • Pip not working in base conda environment
  • Git: Create a branch from unstaged/uncommitted…
  • Push git commits & tags simultaneously
  • How do I remove a submodule?
  • Memcached vs. Redis?
  • Logging best practices
  • Windows git "warning: LF will be replaced by CRLF",…
  • Is there a way to cache GitHub credentials for…
  • How to git reset --hard a subdirectory?
  • How to use Regular Expressions (Regex) in Microsoft…
  • Why does git perform fast-forward merges by default?
  • Oracle: If Table Exists
  • Octave using 'for' statement to show two animations…
  • How to set level logging to DEBUG in Tomcat?
  • How do I install Java on Mac OSX allowing version switching?
  • Is it possible to use pip to install a package from…
  • Cannot update nested dictionary properly
  • Difference between git checkout --track…
  • Why does git say "Pull is not possible because you…
  • How do I ignore files in a directory in Git?
  • Are multiple `.gitignore`s frowned on?
  • Playing HTML5 video on fullscreen in android webview
  • git status shows modifications, git checkout --…
  • How to configure Git post commit hook
  • git rm - fatal: pathspec did not match any files
  • Why does C++ code for testing the Collatz conjecture…
  • What exactly does the "u" do? "git push -u origin…
  • What is git tag, How to create tags & How to…
  • Remove sensitive files and their commits from Git history
  • git add only modified changes and ignore untracked files
  • The definitive guide to form-based website authentication
  • How to build an android library with Android Studio…
  • How to create and publish a Vuejs component on NPM
  • Git's famous "ERROR: Permission to .git denied to user"
  • How do I clone a single branch in Git?
  • How does PHP 'foreach' actually work?
  • What are the undocumented features and limitations…
  • "Thinking in AngularJS" if I have a jQuery background?
  • Getting started with Haskell
  • Smart way to truncate long strings
  • Giving multiple URL patterns to Servlet Filter
  • Git submodule head 'reference is not a tree' error
  • How can I switch to another branch in git?
  • How do I delete a Git branch locally and remotely?
  • "git rm --cached x" vs "git reset head --​ x"?
  • Centering in CSS Grid
  • Importing a GitHub project into Eclipse

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to vertically center a container in Bootstrap?

Next Post:

Remove leading or trailing spaces in an entire column of data

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error