.DS_Store文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_37490221/article/details/82902846

.DS_Store为什么讨厌

在使用MacOS的情况下,你会发现很多文件夹下面都会产生.DS_Store文件,然后在git下就讨厌了。

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .DS_Store
        src/.DS_Store
        src/main/.DS_Store
        src/main/java/.DS_Store
        src/main/java/com/.DS_Store

nothing added to commit but untracked files present (use "git add" to track)

我们要么不管将其提交到git上也无大碍,但是必然碍眼。当然,我们也可以将其添加到.gitignore文件中,这样就不会总是提示.DS_Store需要提交了。但是最好的方法还是从根源处解决,就是不让.DS_Store文件产生。当然,删除会有影响,但影响不大。

解决方式

1.设置.DS_Store的不产生

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

2.删除原有.DS_Store

sudo find / -name ".DS_Store" -depth -exec rm {} \;

再看我们的git status就干净了

nothing to commit, working tree clean

参考:

https://blog.csdn.net/csnewdn/article/details/54847645
https://blog.csdn.net/autoliuweijie/article/details/52805631
https://www.baidu.com/link?url=PLnY9GaKAbiz-mw4qPrZfC00OKpu8jgVWqD0SuxBKtWUyy1uO-sZFtuxqlunpr57o_eFn3fW-qbd2te9YbJojq&wd=&eqid=cdf9a4fc000779b4000000025baf791c

猜你喜欢

转载自blog.csdn.net/weixin_37490221/article/details/82902846