ignoring any 'bin' directory on a git project

前端 未结 15 1823
暖寄归人
暖寄归人 2020-11-22 16:45

I have a directory structure like this:

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

Inside main and tools, and any other directory, at an

15条回答
  •  耶瑟儿~
    2020-11-22 17:19

    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
    

提交回复
热议问题