It's worth noting, also, that git aliases are (or should be) aliased within git, as it adds a lot of nice features:
$git aliasunstage = reset HEAD --
$git unstage --help# or$git help unstage
'unstage' is aliased to 'reset HEAD --'
$git unstag
git: 'unstag' is not a git command. See 'git --help'.
The most similar command is
unstage
That's a lot less terribad than wrapping the same thing in a shell alias or function. Shell aliases for git commands are especially dumb because you're both circumventing many of git's better features, and creating something that's susceptible to all of the issues raised here.
(It's almost as if, knowing their command structure might be... let's say "less than intuitive", the git developers at least decided to include good tools for mitigating that problem.)
I have also seen some really long/complex-looking git aliases that are really hard to follow, like:
[alias]
foo = !"f() { some; really && long | function onliner || with lots of $(sed) && awk '{print $1}' && then call --it at 'the' end ; } ; f"
For these cases, I would recommend creating an executable script placed somewhere in your $PATH named git-foo and git will expose this as a subcommand, like $ git foo. Just like git-extras.
It's worth noting, also, that
git
aliases are (or should be) aliased withingit
, as it adds a lot of nice features:That's a lot less terribad than wrapping the same thing in a shell alias or function. Shell aliases for git commands are especially dumb because you're both circumventing many of git's better features, and creating something that's susceptible to all of the issues raised here.
(It's almost as if, knowing their command structure might be... let's say "less than intuitive", the git developers at least decided to include good tools for mitigating that problem.)
I have also seen some really long/complex-looking git aliases that are really hard to follow, like:
For these cases, I would recommend creating an executable script placed somewhere in your
$PATH
namedgit-foo
and git will expose this as a subcommand, like$ git foo
. Just like git-extras.Agreed, as an alias abuse that's just obnoxious.
Actually I guess
git alias
is part of git-extras, not core git. I guess I never noticed before, since it's just sort of always been there.