[英]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.