简体   繁体   English

我如何跨拉保持git config条目

[英]how do I keep git config entries across pulls

I have a git repo and I'd like to set a config entry so that anyone who pulls gets that config entry. 我有一个git repo,我想设置一个配置项,以便任何拉动的人都可以获取该配置项。

The specifics are that I have a sqlite3 database in the repo, and I'd like to configure git diff to show text versions of the database. 具体是我在仓库中有一个sqlite3数据库,并且我想配置git diff来显示数据库的文本版本。

I have a .gitattributes file in the repo that makes git use the diff "sqlite3": 我在仓库中有一个.gitattributes文件,该文件使git使用diff“ sqlite3”:

*.sqlite3 diff=sqlite3

but the sqlite3 diff needs to be defined in a git config section, like so: 但是sqlite3 diff需要在git config部分中定义,如下所示:

[diff "sqlite3"]
    binary = true
    textconv = "echo .dump | sqlite3"

Currently I have tried putting it in the .git/config file, but it is not defined when pulling from this repo. 目前,我尝试将其放在.git / config文件中,但是从此存储库中提取文件时未定义它。

A workaround is to put it in the .git/config or ~/.gitconfig of each user, but I'd like it to be automatic. 一种解决方法是将其放在每个用户的.git / config或〜/ .gitconfig中,但我希望它是自动的。

If those users have access to a common shared folder, you can take advantage of a template directory use in git init --template=... . 如果这些用户有权访问公共共享文件夹,则可以利用git init --template=...中的模板目录

That template directory can contain a config file which would be copied during the initialization of the repo by a user. 该模板目录可以包含一个config文件,该文件将在用户初始化存储库期间复制。

Other than that, a config isn't shared between repos instances. 除此之外,配置没有在回购实例之间共享。


The alternative is to version a script which can execute the appropriate git config commands you want your users to run. 替代方法是对脚本进行版本控制,该脚本可以执行您希望用户运行的适当git config命令。
And have a README explicit enough to clearly indicate the users of your rpeo they should run said script. 并具有足够明确的README ,以清楚地指示您的rpeo用户应该运行所述脚本。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM