微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

shell变量扩展在git config

我有一个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添加符号链接到此目录。

原文地址:https://www.jb51.cc/bash/389904.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐