ignoring any 'bin' directory on a git project

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

    The .gitignore of your dream seems to be:

    bin/
    

    on the top level.

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

    [Bb]in will solve the problem, but... Here a more extensive list of things you should ignore (sample list by GitExtension):

    #ignore thumbnails created by windows
    Thumbs.db
    #Ignore files build by Visual Studio
    *.user
    *.aps
    *.pch
    *.vspscc
    *_i.c
    *_p.c
    *.ncb
    *.suo
    *.bak
    *.cache
    *.ilk
    *.log
    [Bb]in
    [Dd]ebug*/
    *.sbr
    obj/
    [Rr]elease*/
    _ReSharper*/
    
    0 讨论(0)
  • 2020-11-22 17:10

    Adding **/bin/ to the .gitignore file did the trick for me (Note: bin folder wasn't added to index).

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

    The ** never properly worked before, but since git 1.8.2 (March, 8th 2013), it seems to be explicitly mentioned and supported:

    The patterns in .gitignore and .gitattributes files can have **/, as a pattern that matches 0 or more levels of subdirectory.

    E.g. "foo/**/bar" matches "bar" in "foo" itself or in a subdirectory of "foo".

    In your case, that means this line might now be supported:

    /main/**/bin/
    
    0 讨论(0)
  • 2020-11-22 17:13

    Step 1: Add following content to the file .gitignore.

    # User-specific files
    *.suo
    *.user
    *.userosscache
    *.sln.docstates
    
    # Build results
    [Dd]ebug/
    [Dd]ebugPublic/
    [Rr]elease/
    [Rr]eleases/
    x64/
    x86/
    bld/
    [Bb]in/
    [Oo]bj/
    
    # Visual Studio 2015 cache/options directory
    .vs/

    Step 2: Make sure take effect

    If the issue still exists, that's because settings in .gitignore can only ignore files that were originally not tracked. If some files have already been included in the version control system, then modifying .gitignore is invalid. To solve this issue completely, you need to open Git Bash or Package Manager Console (see screenshot below) to run following commands in the repository root folder.

    $ git rm -r --cached .
    $ git add .
    $ git commit -m 'Update .gitignore'

    Then the issue will be completely solved.

    0 讨论(0)
  • 2020-11-22 17:14
    [Bb]in/
    

    matches both upper and lower case

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