git - 如何在没有 .gitignore 或全局设置的情况下忽略 Git 存储库中的文件?

标签 git

我尝试将一个临时但不是那么临时的文件添加到 Git 存储库而不将其添加到索引。我不想将它添加到 .gitignore 或像 ~/.gitignore_global 这样的文件,因为它只会适用于特定的存储库。

有没有什么方法可以忽略要在特定存储库中编制索引的文件而不索引我想忽略它的事实?

最佳答案

您可以将忽略模式放在 $GIT_DIR/info/exclude 中,以便它仅适用于存储库而不是每个存储库。

来自手册:

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.

关于git - 如何在没有 .gitignore 或全局设置的情况下忽略 Git 存储库中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8482315/

相关文章:

git - 文件夹未推送到 GitHub,仅显示为图标

git - 如何仅为特定分支创建 Git 标签?

git - 在特定项目的 gitlab 仪表板中 stash 项目事件

git - 如何让 git push 运行得更快

eclipse - gitignore 用于 eclipse 项目的文件夹

php - 无法从 dist : There was an error extracting the ZIP file. 损坏文件下载 symfony/finder?

macos - Git 存储库图标

git - 他们是否可以仅针对当前推送将 Push.default 设置为 `current`

Git - merge 到未更新的分支

git pull 与 repo 中的 gzip 文件?