Quantcast
Channel: Programming – Gea-Suan Lin's BLOG
Viewing all articles
Browse latest Browse all 103

Git 的 hasconfig:remote.*.url:

$
0
0

在「How I configure my Git identities (benji.dog)」這邊看到的文章:「How I configure my Git identities」。

裡面在講 Git 的設定,以往我們習慣依據環境放到不同目錄裡 (像是公司的 repository 放到 work/),再加上 includeIf 去針對不同目錄給不同的值 (像是 email),這個功能是在 2017 年五月出的 Git 2.13 引入的,當初 GitHub 也有針對這個功能寫了一篇介紹:「Git 2.13 has been released」。

不過文章裡面提到了另外一個參數 hasconfig:remote.*.url: 可以用,翻了一下 Git 的 release note 目錄,都沒看到這個 feature,直接查 git-config 的 manual 可以看到是 2022 年四月的 2.36.0 加進去的。

這個功能的好處是更彈性,repository 都混在一起也還是可以透過 remote url 條件給不同的設定值。

不過這邊要注意一下版本支援度的問題,目前還在 LTS 期間的 Ubuntu 20.04 (到明年四月) 裡面的 Git 還是 2.25.1,看起來剛好錯過了:「Ubuntu – Details of package git in focal」,如果要用的話可以考慮 PPA 版本:「Git stable releases : “Ubuntu Git Maintainers” team」。


Viewing all articles
Browse latest Browse all 103