██▓ █ ██ ██ ▄█▀ ███▄ ▄███▓ ▓█████▄ ▓█████ ██▒ █▓
▓██▒ ██ ▓██▒ ██▄█▒ ▓██▒▀█▀ ██▒ ▒██▀ ██▌▓█ ▀▓██░ █▒
▒██░ ▓██ ▒██░▓███▄░ ▓██ ▓██░ ░██ █▌▒███ ▓██ █▒░
▒██░ ▓▓█ ░██░▓██ █▄ ▒██ ▒██ ░▓█▄ ▌▒▓█ ▄ ▒██ █░░
░██████▒▒▒█████▓ ▒██▒ █▄▒██▒ ░██▒ ██▓ ░▒████▓ ░▒████▒ ▒▀█░
░ ▒░▓ ░░▒▓▒ ▒ ▒ ▒ ▒▒ ▓▒░ ▒░ ░ ░ ▒▓▒ ▒▒▓ ▒ ░░ ▒░ ░ ░ ▐░
░ ░ ▒ ░░░▒░ ░ ░ ░ ░▒ ▒░░ ░ ░ ░▒ ░ ▒ ▒ ░ ░ ░ ░ ░░
░ ░ ░░░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░
You can add your own git commands
2025-06-15
Tags: git, shellHere's something really cool. You can add your own commands to git by simply prepending a script with git- and adding it to your $PATH.
For example, create a script called git-root which outputs the root directory of a git worktree:
#!/usr/bin/env bash
git rev-parse --show-toplevel
Having saved it, added it to a directory in our path, and marked it as executable, we will be able to execute it just like any other git command:
git root
And that should execute the script, showing the output.
Please share any handy scripts you've added as git commands in the comments!