Hacker News new | ask | show | jobs
by AdieuToLogic 172 days ago
On a related note, git supports incorporating custom commands via executables available in the `PATH` having the naming convention of:

  git-<command name>
Where "command name" in this case would be `archive-branch` and could be defined thusly:

  #!/bin/sh
  # git-archive-branch

  git_branch="${1:-$(git branch --show-current)}"

  git co main &&
    git tag archive/$git_branch $git_branch &&
    git branch -D $git_branch
It then could be invoked the same as the alias:

  git archive-branch ...
2 comments

Oh oh. Your co alias leaked :)
Not the gp but I can't live without co/ci/br now.
Sure. I cannot imagine anyone living without the most common aliases anymore, but in a script you either need to alias again, or expand. Happens so often to me also.
Why is this useful? Why would someone care about typing `git archive-branch` instead of `git-archive-branch`?
Consistency: not needing to remember under which alternative methods any command was found under.