简体   繁体   English

如何忽略没有.gitignore的Git存储库中的文件或全局设置?

[英]How to ignore a file in a Git repository without .gitignore nor a global setting?

I try to add a temporary-but-not-so-temporary file to a Git repository without adding it to the index. 我尝试将一个临时但不是那么临时的文件添加到Git存储库而不将其添加到索引中。 I don't want to add it to a .gitignore nor to a file like ~/.gitignore_global because it would just apply for a specific repository. 我不想将它添加到.gitignore,也不想添加到〜/ .gitignore_global这样的文件,因为它只适用于特定的存储库。

Is there any way to ignore a file to be indexed in a specific repository without indexing the very fact that I want to ignore it ? 有没有办法忽略要在特定存储库中编制索引的文件而不索引我想忽略它的事实?

You can place the ignore patterns in $GIT_DIR/info/exclude so that it will be applicable to only the repo and not every repo. 您可以将忽略模式放在$GIT_DIR/info/exclude这样它就只适用于repo而不是每个repo。

From the manual: 从手册:

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (eg, 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_DIR / info / exclude文件。

Avoid running git add on the file you don't want in your repository or... 避免在存储库中不需要的文件上运行git add或...

Local per-repo rules can be added to the .git/info/exclude file in your repo. 可以将本地per-repo规则添加到repo中的.git / info / exclude文件中。 These rules are not committed with the repo so they are not shared with others. 这些规则不会与回购协议一起提交,因此不会与其他人共享。 This method can be used for locally-generated files that you don't expect other users to generate, like files created by your editor. 此方法可用于本地生成的文件,您不希望其他用户生成这些文件,例如编辑器创建的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 忽略git文件而不在.gitignore中定义文件 - Ignore file with git without defining it in .gitignore 如何使用git忽略文件-不添加到.gitignore - How to ignore files with git - without adding to .gitignore 忽略特定存储库的全局gitignore规则 - Ignore a global gitignore rule for specific repository 如何在不修改.gitignore的情况下让git忽略对特定文件的本地更改? - How can I have git ignore local changes to a specific file, without modifying the .gitignore? IntelliJ IDEA如何甚至不使用.gitignore文件自动从Git存储库中检测并忽略目标目录? - How IntelliJ IDEA automatically detects and ignore target directory from a Git repo without even using .gitignore file? 你如何让 Git 在不使用.gitignore 的情况下忽略文件? - How do you make Git ignore files without using .gitignore? 如何重置git忽略的文件(未在.gitignore中配置)? - How can I reset a file ignore by git (not configured in .gitignore)? 如何使用 .gitignore 文件正确忽略来自 git 的文件? - How to properly ignore files from git using .gitignore file? Git - 如何在从裸存储库结帐期间排除 .gitignore 文件? - Git - How to exclude .gitignore file during checkout from bare repository? 排除提交中的文件-忽略git中的文件(.gitignore) - excluding file in commit - ignore file in git (.gitignore)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM