Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Git

Git: Fix an Alias Expanding Differently Inside a CI Runner

- 25.11.26 - ErcanOPAK

🔀 Git: Fix an Alias Expanding Differently Inside a CI Runner

A git alias defined with a ! shell-out prefix runs through whatever shell git invokes it with, and that shell can differ between a developer’s machine and a CI runner’s minimal container image — bash-specific syntax that works fine locally can behave differently, or fail outright, under whatever /bin/sh happens to be symlinked to on that particular runner, making the exact same alias command produce different output in CI than it does anywhere else.

🔎 The Problem

[alias]
  lastlog = "!h=$(git log -1 --format=%H); echo ${h:0:8}"

Local machine (bash):      prints an 8-character short hash, as intended
CI runner (dash as /bin/sh): "bad substitution" error - ${h:0:8} is a
  bash-ism dash doesn't support, pipeline step fails with no clear reason

✅ Fix: Pin the Interpreter, Don’t Assume It Matches Your Shell

  • Avoid bash-specific syntax inside a !-prefixed alias if it also needs to run unmodified in CI — check what shell the runner actually invokes it through rather than assuming it matches your local default.
  • Pin the alias to an explicit interpreter inside the alias body (!bash -c '...') rather than depending on whatever /bin/sh happens to be symlinked to on that runner image.
  • Test the exact alias command inside the same container image CI uses, not just a local terminal, since a shell or locale difference between environments is a common silent cause of an alias “working everywhere except CI.”

🚨 Why This Is Dangerous

  • A CI pipeline step that depends on a git alias behaving identically to local can fail outright, or worse, silently produce different output that downstream automation consumes without anyone noticing it’s subtly wrong.

A git alias that starts with ! isn’t running your shell — it’s running whatever shell happens to be standing in for /bin/sh wherever it’s called.

— Version Control Tip

Related posts:

Git: Use Git Bisect to Find Which Commit Introduced a Bug

Git: Use Git Bisect to Find Which Commit Introduced a Bug

Git: The Ultimate Safety Net - Recovering 'Deleted' Work with Reflog

Git: The Ultimate Safety Net - Recovering 'Deleted' Work with Reflog

Git: Fix a .gitattributes export-ignore Rule That's Silently Skipped Because the Repo Was Cloned Ins...

Git: Fix a .gitattributes export-ignore Rule That's Silently Skipped Because the Repo Was Cloned Ins...

Views: 12
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

C#: Fix a Custom Awaiter Resuming on the Wrong Thread Context
C#: Fix a Generic Attribute Losing Its Type Argument at Runtime

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com