从 github 拉取文件时如何忽略文件?

How do I ignore files when pulling from github?

我在 Ruby 工作,当我从 Github 拉出时想忽略我的配置文件。

我收到的错误是: "error: Your local changes to the following files would be overwritten by merge: config/database.yml"

我尝试过的事情:

1) 我将文件路径添加到我的 .gitignore 位于我的应用程序根目录中。

2) 我将文件路径添加到我的全局 .gitignore

3) I 运行 git update-index --assume-unchanged /config/database.yml 来自我的应用程序根目录

4) I 运行 git update-index --skip-worktree config/database.yml 来自我的应用程序 root

我在计算机上的几个不同文件夹中有同一个应用程序的多个实例。应用程序的其他实例遵守 assume-unchanged 命令。我不确定我错过了什么。

考虑在提取之前存储您的本地更改:

git stash
git pull
git stash pop

如果您存储的文件在源上发生更改,则可能存在合并冲突。