ignoring any 'bin' directory on a git project

前端 未结 15 1627
暖寄归人
暖寄归人 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:14

    If you're looking for a great global .gitignore file for any Visual Studio ( .NET ) solution - I recommend you to use this one: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

    AFAIK it has the most comprehensive .gitignore for .NET projects.

    0 讨论(0)
  • 2020-11-22 17:18

    Literally none of the answers actually worked for me; the only one that worked for me was (on Linux):

    **/bin
    (yes without the / in the end)
    
    git version 2.18.0 
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2020-11-22 17:21

    If the pattern inside .gitignore ends with a slash /, it will only find a match with a directory.

    In other words, bin/ will match a directory bin and paths underneath it, but will not match a regular file or a symbolic link bin.


    If the pattern does not contain a slash, like in bin Git treats it as a shell glob pattern (greedy). So best would be to use simple /bin.

    bin would not be the best solution for this particular problem.

    0 讨论(0)
  • 2020-11-22 17:22

    As a notice;

    If you think about .gitignore does not work in a way (so added foo/* folder in it but git status still showing that folder content(s) as modified or something like this), then you can use this command;

    git checkout -- foo/*

    0 讨论(0)
  • 2020-11-22 17:24

    for 2.13.3 and onwards,writing just bin in your .gitignore file should ignore the bin and all its subdirectories and files

    bin

    0 讨论(0)
提交回复
热议问题