Conditional Git Configuration
blog.scottlowe.org
Conditional Git Configuration
1–10 of 73 posts
Re: Conditional Git Configuration
#2I did not know about `includeIf`...this allows getting rid of the hacks I used to achieve something similar, great!
Re: Conditional Git Configuration
#3Oh 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!
Re: Conditional Git Configuration
#4Useful 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.
Re: Conditional Git Configuration
#5man 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.
Re: Conditional Git Configuration
#6Actually useful, thanks
Re: Conditional Git Configuration
#7I use it to set my personal and my work email to different projects
Re: Conditional Git Configuration
#8Nice.
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.
Re: Conditional Git Configuration
#9Oh 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!
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.
Re: Conditional Git Configuration
#10Oh this is pretty useful! Thanks!