加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell变量扩展在git config

发布时间:2020-12-15 09:20:49 所属栏目:安全 来源:网络整理
导读:我有一个shell变量,指向所有我的配置文件所在的目录。让我们假设变量使用export RC = $ HOME / rc创建。我有一个全局忽略文件在配置目录:?/ rc / globalgitignore。 我的问题是,我如何扩展我的.gitconfig文件中的RC变量? 我已经尝试以下: excludesfile
我有一个shell变量,指向所有我的配置文件所在的目录。让我们假设变量使用export RC = $ HOME / rc创建。我有一个全局忽略文件在配置目录:?/ rc / globalgitignore。

我的问题是,我如何扩展我的.gitconfig文件中的RC变量?

我已经尝试以下:

> excludesfile = $ RC / globalgitignore
> excludesfile =!$ RC / globalgitignore
> excludesfile =!echo $ RC / globalgitignore
> excludesfile =!$(echo $ RC / globalgitignore)

这些解决方案都没有效果。

这是唯一的方式,如果我输入完整的路径:excludesfile =?/ rc / globalgitignore,但是我必须更改路径如果将我的rc目录移动到不同的位置。

你不能。 git-config(1)不支持环境变量扩展,但仅限于类型转换和路径扩展:

The type specifier can be either –int or –bool,to make git config ensure that the variable(s) are of the given type and convert the value to the canonical form (simple decimal number for int,a “true” or “false” string for bool),or –path,which does some path expansion (see –path below). If no type specifier is passed,no checks or transformations are performed on the value.

–path的文档说明:

–path

git-config will expand leading ~ to the value of $HOME,and ~user to the home directory for the specified user. This option has no effect when setting the value (but you can use git config bla ~/ from the command line to let your shell do the expansion).

术语“扩展”不会出现在git-config(1)中的任何不同的上下文中。那么你是怎么得到应该的想法,因为没有这样的特征记录在任何地方?

为了扩展环境变量,你必须自己预处理Git配置文件,即通过创建模板文件,并在将文件复制到$ HOME目录之前用脚本展开变量。

如果它是关于点文件管理,然后做,所有人做的:将它们放在一个目录,并从$ HOME添加符号链接到此目录。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读