Aliases

    • Learn how to setup aliases and shortcuts for git commands

    Add the following to the .gitconfig file in your $HOME directory.

    We’ve covered the commit and status commands already. And we just covered the log command in the previous lab. The checkout command will be coming up soon.

    With these aliases defined in the .gitconfig file you can type wherever you used to have to type git checkout. Likewise with git st for git status and git ci for git commit. And best of all, git hist will allow you to avoid the really long log command.

    For the most part, I will continue to type out the full command in these instructions. The only exception is that I will use the hist alias defined above anytime we need to see the git log output. Make sure you have a alias setup in your .gitconfig file before continuing if you wish to follow along.

    We’ve added a few aliases for commands we haven’t covered yet. The git branch command will be coming up soon. And the git cat-file command is useful for exploring git, which we will see in a little while.

    Note: This section is for folks running a posix-like shell. Windows users and other non-posix shell users can feel free to skip to the next lab.

    .profile

    The gco abbreviation for git checkout is particularly nice. It allows me to type:

    to checkout a particular branch.

    And yes, I do mistype git as get or got often enough to create aliases for them.