.gitignore exclude folder but include specific subfolder

后端 未结 17 1652
一个人的身影
一个人的身影 2020-11-21 06:36

I have the folder application/ which I add to the .gitignore. Inside the application/ folder is the folder application/language

17条回答
  •  我寻月下人不归
    2020-11-21 07:14

    Just another example of walking down the directory structure to get exactly what you want. Note: I didn't exclude Library/ but Library/**/*

    # .gitignore file
    Library/**/*
    !Library/Application Support/
    !Library/Application Support/Sublime Text 3/
    !Library/Application Support/Sublime Text 3/Packages/
    !Library/Application Support/Sublime Text 3/Packages/User/
    !Library/Application Support/Sublime Text 3/Packages/User/*macro
    !Library/Application Support/Sublime Text 3/Packages/User/*snippet
    !Library/Application Support/Sublime Text 3/Packages/User/*settings
    !Library/Application Support/Sublime Text 3/Packages/User/*keymap
    !Library/Application Support/Sublime Text 3/Packages/User/*theme
    !Library/Application Support/Sublime Text 3/Packages/User/**/
    !Library/Application Support/Sublime Text 3/Packages/User/**/*macro
    !Library/Application Support/Sublime Text 3/Packages/User/**/*snippet
    !Library/Application Support/Sublime Text 3/Packages/User/**/*settings
    !Library/Application Support/Sublime Text 3/Packages/User/**/*keymap
    !Library/Application Support/Sublime Text 3/Packages/User/**/*theme
    

    > git add Library

    > git status

    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        new file:   Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap
        new file:   Library/Application Support/Sublime Text 3/Packages/User/ElixirSublime.sublime-settings
        new file:   Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
        new file:   Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings
        new file:   Library/Application Support/Sublime Text 3/Packages/User/RESTer.sublime-settings
        new file:   Library/Application Support/Sublime Text 3/Packages/User/SublimeLinter/Monokai (SL).tmTheme
        new file:   Library/Application Support/Sublime Text 3/Packages/User/TextPastryHistory.sublime-settings
        new file:   Library/Application Support/Sublime Text 3/Packages/User/ZenTabs.sublime-settings
        new file:   Library/Application Support/Sublime Text 3/Packages/User/adrian-comment.sublime-macro
        new file:   Library/Application Support/Sublime Text 3/Packages/User/json-pretty-generate.sublime-snippet
        new file:   Library/Application Support/Sublime Text 3/Packages/User/raise-exception.sublime-snippet
        new file:   Library/Application Support/Sublime Text 3/Packages/User/trailing_spaces.sublime-settings
    

提交回复
热议问题