TWIL
git
Katie demonstrating Git alias configuration on a computer screen, promoting efficient and inclusive Source Control Management practices.

Welcome to another enlightening edition of TWIL, the series dedicated to fostering continuous learning in the ever-evolving landscape of software development. This week, join Katie as she navigates the trail of Git aliases with default branch complexities. Her insights dive into creating adaptable Git aliases amidst the shifts from "master" to more inclusive terms like "main" or "primary," streamlining your Git workflow with precision and inclusivity. Save time and prevent hiccups by harnessing her tips to refine your Source Control Management practices, ensuring your Git experience stays ahead of the curve.

Git aliases with default branch

Git aliases that assume that your default branch is called "master" can be problematic (for example; having "develop" as the default branch, or the industry shift to "main", "primary". etc., etc.)

default = "!f() { git remote show ${1:-'origin'} | grep 'HEAD branch' | sed 's/.*: //'; }; f"

Some other aliases that build off of this one that I've found helpful:

cd = "!f() { git checkout $(git default); }; f"

rd = "!f() { git rebase $(git default); }; f"

up = "!f() { git remote update origin && git pull origin ${1:-$(git default)}; }; f"

update = "!f() { git cd && git up && git co - && git rd; }; f"
  • git
Katie Linero's profile picture
Katie Linero

Senior Software Engineer

Related Posts

September 12, 2024 • Frank Valcarcel

Benchmarking AI: Evaluating Large Language Models (LLMs)

Large Language Models like GPT-4 are revolutionizing AI, but their power demands rigorous assessment. How do we ensure these marvels perform as intended? Welcome to the crucial world of LLM evaluation.

Image for TWIL post depicting ActiveRecord range query examples in Ruby on Rails, enhancing database search efficiency.
September 16, 2020 • Frank Valcarcel

TWIL 2020-09-11

This week’s TWIL features Katie’s guide to using new range syntax in ActiveRecord queries, revealing how to efficiently search databases in Ruby on Rails.