Ignore symbolic links in .gitignore

后端 未结 2 670
不知归路
不知归路 2021-01-02 03:41

Is it possible to tell Git to ignore symlinks ? I\'m working with a mixed Linux / Windows environment and, as you know, symlinks are handled very differently between the two

2条回答
  •  鱼传尺愫
    2021-01-02 04:02

    No, it is not possible to do this globally. However, if you have lots of symlinks here is a bash script that you can use to easily add them to your repo's .gitignore file:

    for f in $(git status --porcelain | grep '^??' | sed 's/^?? //'); do
        test -L "$f" && echo $f >> .gitignore; # add symlinks
        test -d "$f" && echo $f\* >> .gitignore; # add new directories as well
    done
    

提交回复
热议问题