Telling git to ignore symlinks

后端 未结 8 1963
说谎
说谎 2020-12-08 06:13

This question has appeared in similar forms here and here, but they don\'t seem to match up with what I\'m looking for.

I\'m making a project in StaticMatic, a Ruby

相关标签:
8条回答
  • 2020-12-08 06:54

    I don't keep the executables, and symlinks in my repository... so I want to omit them as well when I do a "git status".

    If, like me, you want to ignore symlinks, directories and executables (ala some of the files in $NAG_HOME/libexec you can add those files into .gitignore as follows:

       file * | egrep 'ELF|symbolic|directory' | awk -F\: '{ print $1 }' >> .gitignore
    
       echo ".gitignore" >> .gitignore
    

    Then, when you do a git status, it won't spit back the list of those files if you have not added them to your repository.

    0 讨论(0)
  • 2020-12-08 06:55

    If you really want to ignore a filename if it's a symlink or file but not if it is a directory, you can add to .gitignore :

    /media
    !/media/
    

    To formulate it like @Chris_Rasys, this will :

    • Ignore - (symlink) ./media
    • Ignore - (file) ./media
    • Do not ignore - (directory) ./media
    • Do not ignore - ./something/media
    • Do not ignore - ./media.bak
    • Do not ignore - ./media-somethingelse
    0 讨论(0)
提交回复
热议问题