如何摆脱卡在远程存储库中的 .DS_Store 文件?

0 git macos heroku

我已经使用正确的 .gitignore 文件重新初始化了我的存储库,但是我的远程 Heroku 中仍然有 .DS_Store 文件。

git pull heroku master 给出:

在此输入图像描述

我怎样才能一劳永逸地摆脱这些文件?

Cod*_*ard 5

看起来您已经提交了这些文件。

添加并提交文件后,git 开始跟踪它们。

您有两个主要选项来忽略这些文件。

  1. 从存储库中删除它们(请参阅下面的代码)
  2. 使用“assume-unchanged”标志将它们标记为从此时起未更改。

在您的情况下,您希望使用第一个选项,因此方法如下。

文件.gitignore指定 Git 应忽略的故意未跟踪的文件。
已被 Git 跟踪的文件不受影响


How to remove commited files and set git to ignore them?

您必须删除并提交,然后它们将被忽略。

# remove the commited files:
git rm --cached .DS_Store

# now add the files to the .gitignore and

# commit and push
git commit -m "Removed..."
git push origin <branch>
Run Code Online (Sandbox Code Playgroud)