1

Beautify Your Git Log with a Single Command

 1 year ago
source link: https://dev.to/pradumnasaraf/beautify-your-git-log-with-a-single-command-2i5
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for Beautify Your Git Log with a Single Command
25 5 4 5 8

Beautify Your Git Log with a Single Command

The standard git log command is functional, providing the necessary information, but it can come across as somewhat dull and verbose. What if there was a way to make the git log not just informative, but also visually appealing? Something like this:

Image description

Yes, it's entirely possible! And the good news is that we can achieve this by simply using a bunch of flags and subcommands. There's no need to install or download anything.

Here's the command:

git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches

But typing this command every time could be tiresome. A solution to this is using Git aliases, which allow you to create shortcuts for lengthy commands. If you're unfamiliar with Git aliases, I recommend reading my recent article that dives into the topic:

Now, let's set up an alias for our beautiful git log command:

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

Now you can invoke the beautified git log using a simpler git lg.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK