Advanced aliases with external commands

If you want the alias to run external shell commands, instead of a Git sub-command, you have to prefix the alias with a !:

$ git config --global alias.echo !echo

Suppose you are annoyed by the canonical git add <file> plus git commit <file> sequence of commands, and you want to do it in a single shot; you can call the git command twice in sequence by creating this alias:

$ git config --global alias.cm '!git add -A && git commit -m'

With this alias you commit a file, adding it before if necessary.

Have you noted that I set the cm alias again? If you set an already configured alias, the previous alias will be overwritten.

There are also aliases that define and use complex functions or scripts, but I'll leave it to the curiosity of the reader to explore these aliases. If you are looking for inspiration, take a look at this GitHub repository at https://github.com/GitAlias/gitalias.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.30.232