Conditional git profile configuration
serverless developer & architect at Elva
Search for a command to run...
serverless developer & architect at Elva
No comments yet. Be the first to comment.
For a long time, both professionally with clients in my consulting work and in the AWS community, I've been evangelizing the "serverless" paradigm shift. To me, it's crystal clear that you should focus on building what differentiates your business, a...

AWS StepFunctions is a fantastic service for orchestrating complex workflows. But testing StepFunctions has always been... tricky. You could execute the entire state machine, observing side effects and final outcomes, but this approach often feels li...

AWS WAF, the managed Web Application Firewall, is a commonly used service to secure APIs, load balancers, and applications. But because of how the pricing model is set up for WAF, the costs can quickly spiral out of control when adhering to the AWS b...

In this post, we'll look at some of the most popular frameworks for building serverless applications on AWS, including their features, strengths, and weaknesses. We'll also look at examples of how each framework can be used to build an example applic...

One of the most significant benefits of serverless is that the development teams can fully own and manage all of their infrastructure themself. Keeping all of that infrastructure in the same CloudFormation stack can sometimes be troublesome however, ...

I always found it inconvenient that I had to either keep changing the email in my .gitconfig every time I wanted to switch between working on a personal project and a work project, or I had to remember to configure the email in each repository as I cloned it. I often forgot and git discipline being something of a pet peeve of mine, I spent way too much time rewriting history just to change my darned email address so that it wouldn't be inconsistent in the git log. I have a problem, I know but let's keep on topic here mmhkay?
Turns out, there's a much easier way to do this. It's possible to conditionally extend the git configuration based on where your repository is located in your file system. That means we can have a global git configuration with all the default configuration and then in a few overrides for all repositories within, for example, the ~/code/work/ folder by adding a little something like this to the ~/.gitconfig file.
// ~/.gitconfig
[user]
name = Sebastian Bille
email = personal@example.com
[includeIf "gitdir:~/code/work/"]
path = ~/code/work/.gitconfig
// ~/code/work/.gitconfig
[user]
email = work@example.com
Now all repositories inside of the ~/code/work/ folder will use your overridden email but all others will keep using the default configuration.
This could of course be used to override or add any other configuration conditionally as well.
If you enjoyed this guide and want to see more, follow me on Twitter at @TastefulElk where I frequently write about serverless tech, AWS and developer productivity!
Happy hacking! 🚀