This post continues my previous post about customizing git.
Once you start using git a lot, you will get tired of typing out commands like,
git status, git branch, and git checkout over and over again. Since git
is really flexible, you can change these commands to git st, git br,
git co respectively.
| Full command | Short command |
|---|---|
git status |
git st |
git branch |
git br |
git checkout |
git co |
You can do these via the terminal by executing these commands
git config --global alias.st status
git config --global alias.br branch
git config --global alias.co checkout
These commands will add or edit your ~/.gitconfig file so that it contains
[alias]
br = branch
co = checkout
st = status
Or, as before, you can edit ~/.gitconfig to add/edit these lines.
As mentioned in my previous post, you can choose to
make these changes for only a particular repository by typing the above commands
inside a repository and replacing the --global option by --local.
Omitting the --global flag is equivalent to using --local because
--local is the default option.
Git offers you an editor to write a commit message after a git commit command. I never got used to
the complexities of vim as an editor, as simple as it is. Writing a commit message should be a simple
affair which can be done within in a terminal. For these reasons, I prefer nano as my favorite
in-terminal editor. Setting the global default editor for git can be done by this command
git config --global core.editor nano
Expectedly, by running this command, we add the following lines to the ~/.gitconfig file
[core]
editor = nano
This post is the part of the Using Git series: