DEV Community

TechWithTy
TechWithTy

Posted on

How This Simple glp Alias Saves Hours in Git

๐Ÿšจ STOP using git log the old way! ๐Ÿšจ

If youโ€™re constantly drowning in a flood of commit hashes, author names, dates, and long messagesโ€”youโ€™re doing it wrong.

I used to type git log like a caveman, getting lost in a sea of unnecessary info. Then I found a BETTER way.

๐Ÿ’ก Meet glpโ€”A Custom Alias That Makes Git Logs Insanely Easier

โœ… What Makes glp Awesome?

  • Compact & Clean โ€“ No more overwhelming walls of text.
  • Color-coded for Clarity โ€“ Instantly spot commit hashes, authors, and times.
  • Relative Time Awareness โ€“ See commits as "5 minutes ago" instead of a full timestamp.

โŒ The Problem With git log

By default, git log is a cluttered mess. Hereโ€™s what you usually get:

commit 87fd12a3b2a45e8df8347d8d4fa0023bd4a5e987
Author: John Doe <johndoe@example.com>
Date:   Tue Feb 13 12:34:56 2024 +0000
Enter fullscreen mode Exit fullscreen mode
Fixed login bug
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’€ Looks complicated and takes forever to read!
โšก The Game-Changer: A Cleaner Git Log (glp)

Instead of using git log, create a custom alias that makes commit logs readable and useful.
๐Ÿ”ง How to Set Up glp

Add this one-liner to your .bashrc or .zshrc file:

alias glp="git log --pretty=format:'%C(yellow)%h%Creset - %C(green)%an%Creset - %C(cyan)%ar%Creset - %s'"
Enter fullscreen mode Exit fullscreen mode

What it does:

โœ… Shows only the commit hash, author, relative time, and message.
โœ… Adds color coding for quick scanning.
โœ… Displays times as "5 minutes ago" instead of a long timestamp.
Enter fullscreen mode Exit fullscreen mode

Now, instead of running git log, just type:

glp

And youโ€™ll get this instead:

1a2b3c - John Doe - 5 minutes ago - Fixed login bug
4d5e6f - Jane Smith - 2 days ago - Updated UI layout
7g8h9i - Dev Ops - 1 week ago - Optimized database query
Enter fullscreen mode Exit fullscreen mode

๐Ÿ˜ So much cleaner, right?!
๐Ÿš€ Why This Saves You Hours

No more scrolling endlessly through an unreadable commit history.
Easier debugging โ€“ Quickly find the last few commits at a glance.
Faster collaboration โ€“ See recent changes by teammates instantly.
Better PR Reviews โ€“ Scan commits effortlessly before merging.
Enter fullscreen mode Exit fullscreen mode

Imagine checking commits 10+ times a dayโ€”this trick saves minutes per check, adding up to hours every month! ๐Ÿ•’
๐Ÿ” Bonus: More Git Log Customization

Want to tweak the alias further? Here are some cool variations:
1๏ธโƒฃ Show Branch & Tags

alias glp="git log --decorate --pretty=format:'%C(yellow)%h%Creset %d - %C(green)%an%Creset - %C(cyan)%ar%Creset - %s'"
Enter fullscreen mode Exit fullscreen mode

โž Displays branch/tag info in the log.
2๏ธโƒฃ Limit to Last 5 Commits

alias glp="git log -n 5 --pretty=format:'%C(yellow)%h%Creset - %C(green)%an%Creset - %C(cyan)%ar%Creset - %s'"
Enter fullscreen mode Exit fullscreen mode

โž Shows only the latest 5 commits.
3๏ธโƒฃ Show Full Timestamp Instead of Relative Time

alias glp="git log --pretty=format:'%C(yellow)%h%Creset - %C(green)%an%Creset - %C(cyan)%ad%Creset - %s' --date=iso"
Enter fullscreen mode Exit fullscreen mode

โž Displays full timestamps instead of "5 minutes ago".

Final Thoughts

Stop using git log the old way!

This simple alias transforms your Git workflow, making commit logs more readable, concise, and useful.

Try it out, tweak it to your liking, and share it with your fellow devs! ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ”ฅ

๐Ÿ’ฌ What do you think? Drop a comment if you found this usefulโ€”or share your own favorite Git productivity tricks! ๐Ÿš€
๐Ÿ›  Need More Dev Productivity Tips?

Follow me for more coding hacks, Git tips, and DevOps tricks! ๐Ÿš€

๐Ÿ”— Find me on Youtube: @techwithty
๐Ÿ”— GitHub: github.com/techwithty

Top comments (0)