DEV Community

Evan Charalampidis
Evan Charalampidis

Posted on

Make your git log look better using a single command

๐Ÿ‘‹ Introduction

Are you tired of sifting through a bland and confusing Git commit history? There's a simple yet powerful command that can give your Git log a much-needed makeover, making it both visually appealing and informative.

๐Ÿš€ Getting Started

Add the following lines to your Git configuration file (usually located at ~/.gitconfig):

[alias]

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

Enter fullscreen mode Exit fullscreen mode

Let's break down the command to understand its magic:

  1. color: Infuses your Git log with vivid colors, making it pop.
  2. graph: Generates a graphical representation of branches and merges.
  3. pretty=format: Customizes the log's format to your liking.

  4. %Cred%h%Creset: Displays commit hash in red.

  5. %C(yellow)%d%Creset: Shows branch and tag names in yellow.

  6. %s: Displays the commit message.

  7. %Cgreen(%cr): Shows the commit's relative time in green.

  8. %C(bold blue)<%an>%Creset: Displays the author's name in bold blue.

  9. abbrev-commit: Shortens commit hash for a cleaner look.

  10. branches: Displays commits from all branches.

Upon running gl, your Git log will transform into an engaging visual journey. Each commit is highlighted with colors, and the log provides valuable insights like commit messages, author names, and relative times. The branching and merging patterns are more apparent, allowing you to follow your project's development path effortlessly.

This command is a game-changer, making your Git log not only aesthetically pleasing but also incredibly functional. Collaborate effectively, track changes efficiently, and understand your project's history at a glance.

๐Ÿ Conclusion

Using the git log command with colourful formatting and visuals spruces up your commit history. It's a simple way to make your git log more organised and helpful, promoting better teamwork and project insight. Give it a whirl!

Github: @imevanc
Twitter: @imevancc

Top comments (0)