[HN Gopher] Conditional Git Configuration
___________________________________________________________________
Conditional Git Configuration
Author : djha-skin
Score : 76 points
Date : 2024-01-10 20:49 UTC (2 hours ago)
(HTM) web link (blog.scottlowe.org)
(TXT) w3m dump (blog.scottlowe.org)
| blux wrote:
| I did not know about `includeIf`...this allows getting rid of the
| hacks I used to achieve something similar, great!
| bloopernova wrote:
| Oh nice, this will remove an annoyance in my dotfiles repo by
| letting me share my gitconfig between 3 different configurations
| (home linux amd64 box, work macOS arm64, client macOS arm64)
|
| Thank you for sharing it!
| nerdponx wrote:
| I just have a "config-private" file that I include in my main
| config, but I ignore it in the dotfiles repo. Git will ignore
| any included file if it does not exist. That lets me customize
| things locally without checking work details into version
| control.
| dvas wrote:
| Useful when you want to have multiple git accounts changing based
| on the path. Thanks for the share! In my case it was changing the
| ssh key based on the project folder.
| tux1968 wrote:
| man git-config, shows that so far there aren't many conditions
| available for testing. The location of the .git directory (as in
| the article). The name of the currently checked out branch. Or a
| pattern match against any remote URL in the configuration.
| _joel wrote:
| Actually useful, thanks
| matheusiacono wrote:
| I use it to set my personal and my work email to different
| projects
| bashtoni wrote:
| Nice.
|
| For years I've been using [direnv](https://direnv.net/) for this,
| setting environment variables which git picks up. This looks like
| a more feature complete equivalent, although to be honest I only
| really need switching of committer email and the SSH key used.
| lxe wrote:
| Oh this is pretty useful! Thanks!
___________________________________________________________________
(page generated 2024-01-10 23:00 UTC)