可以有条件地设置gitconfig选项吗? [英] Can gitconfig options be set conditionally?
问题描述
我宁愿不为这些远程服务器创建并维护第二个 .gitconfig
。有没有办法做到这一点:
[core]
if [[$ IS_REMOTE -eq 1] ]。那么
editor =vim
else
editor =subl -n -w
fi
在哪里设置$ IS_REMOTE根据主机名?
由于无法测试环境变量并以编程方式更改.gitconfig,并且由于脚本编写两个.gitconfig文件的创建感觉比我想提出的工作要多,我只需创建两个.gitconfig文件。在那些我可以设置Sublime Text 2作为编辑器的机器上,并且可以控制合并工具和diff工具,我将使用primarygitconfig作为我的符号链接的目标。在那些没有ST2作为选项的机器上,我将使用secondarygitconfig文件。
Via Github I use the same set of "dot files" on several different computers and servers. On the Macs and Linux boxes under my direct control I have Sublime Text 2 installed and set up as my git merge and commit editor of choice. However, on remote (i.e., not under my direct control) servers I would select to use vim.
I would rather not create and maintain a second .gitconfig
for those remote servers. Is there a way to do something like this:
[core]
if [[ $IS_REMOTE -eq 1 ]]; then
editor = "vim"
else
editor = "subl -n -w"
fi
where I've somehow set $IS_REMOTE based on the hostname?
Since it isn't possible to test an environment variable and programmatically alter the .gitconfig, and since scripting the creation of two .gitconfig files feels like more work than I really want to put forth, I'm just going to create two .gitconfig files. On those machines where I can setup Sublime Text 2 as my editor, and have control over the merge tool and diff tool, I'll use the "primary" gitconfig as the target of my symbolic link. On those machines where I don't have ST2 as an option, I'll use the "secondary" gitconfig file.
这篇关于可以有条件地设置gitconfig选项吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!