Interview Prep/Git & GitHub/Config, Line Endings, Files and Platform Quirks

Your alias fails with `expansion of alias 'cleanup' failed; 'branch' is not a git command`, or runs only half of what you wrote.

IntermediateTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer

Likely causes → You wrote a shell pipeline or $(...) in a normal alias. Without a leading !, aliases are passed to Git as arguments, not to a shell, and quoting is easily broken in .gitconfig.

Diagnose → git config --get alias.cleanup and GIT_TRACE=1 git cleanup.

Fix → Prefix shell aliases with ! and quote them correctly:

git config --global alias.cleanup '!git branch --merged main | grep -v -E "^\*|main$" | xargs -r git branch -d'

Shell aliases run from the repo's top-level directory; use $GIT_PREFIX if you need the original subdirectory.

Prevent → Put anything non-trivial in a script named git-cleanup on your PATH; Git runs it as git cleanup.

All Git & GitHub questions Roadmap: Git & GitHub

More on Config, Line Endings, Files and Platform Quirks