git aliases

Basics of git aliases

Use git config alias.* , Luke. Or edit your .gitconfig file.

An example will be a shortcut for git branch – br:

git config alias.br branch

Or add the following to your .gitconfig (~/.gitconfig  in Linux):

[alias]
br = branch

Global/local aliases

Aliases can be applied on a global level (for the whole operating system) or locally – for the current repo.

To create a local alias you may use git config alias.*  command:

git config alias.br branch

To do the same on a global level you can modify your global configuration file (usually ~/.gitconfig ) as it was shown above or run git config with –global modifier:

git config --global alias.br branch

Some useful aliases

git config alias.st status
git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)\<%an\>%Creset' --abbrev-commit --date=relative"

Here st will be a shortcut for status and lg will output nicely formatted commit history.

Resources

Leave a Reply

Your email address will not be published. Required fields are marked *