This content originally appeared on Level Up Coding - Medium and was authored by Rahul Beniwal
Mastering Git log.
Check log with git log
Hi fellow developer,
Git is an indispensable tool in our daily workflow, and mastering it can significantly enhance your productivity. Today, I’ll share some of the git aliases I use to save time and streamline my processes.
Enhanced git log
By default, git log provides a wealth of information, but sometimes it can be overwhelming. By adding some parameters, you can tailor the output to show only the details you need.
Basic git log
Here’s the default output of git log
🕙 10:11:44 ❯ git log
commit 47d8603552db63a8cdaa82f3e19cebd4beba5fcc (HEAD -> master)
Author: Rahul Beniwal <rahulbeniwal18112002@gmail.com>
Date: Thu Jul 18 10:09:29 2024 +0530
Adding .env templates
Customized git log
To make the log more readable and informative, you can use the following alias:
git log --pretty=format:'%C(red)%h%Creset %C(yellow)%d%Creset %s %C(green)(%cr) %C(yellow)<%an>%Creset'
This command formats the log to show:
- The commit hash in red.
- The branch information in yellow.
- The commit message.
- The relative time of the commit in green.
- The author’s name in yellow.
Example output:
🕙 10:20:22 ❯ git log --pretty=format:'%C(red)%h%Creset %C(yellow)%d%Creset %s %C(green)(%cr) %C(yellow)<%an>%Creset'
867f65e (HEAD -> master, origin/master, origin/HEAD) added some graph questions (6 months ago) <Rahul Beniwal>
ddcaba5 adding builder pattern (10 months ago) <Rahul Beniwal>
35c1a4d adding jupyter ipynbs (1 year, 2 months ago) <Rahul Beniwal>
0d1d70b adding more revision snippets (1 year, 4 months ago) <Rahul Beniwal>
17f3bf2 Assign some pretty decorator code (1 year, 4 months ago) <Rahul Beniwal>
f1ea4ba Adding SingleTon and ProtoType Pattern (1 year, 5 months ago) <Rahul Beniwal>
5cdf4af adding dict (1 year, 7 months ago) <Rahul>
a3807de updating more iterator code (1 year, 7 months ago) <Rahul Beniwal>
561c732 adding advance feature of dict (1 year, 7 months ago) <Rahul Beniwal>
0d03bac moving file to folder (1 year, 7 months ago) <Rahul Beniwal>
d99df86 adding new ipynbs (1 year, 7 months ago) <Rahul>
e4ac52e adding pydantic ipynb (1 year, 7 months ago) <Rahul>
90f5336 adding decorators.ipynb (1 year, 7 months ago) <Rahul Beniwal>
10bf2f1 adding more ipynbs (1 year, 7 months ago) <Rahul Beniwal>
a2fd155 adding pydantic and type hinting (1 year, 7 months ago) <Rahul Beniwal>
f14fc63 adding typing (1 year, 7 months ago) <Rahul Beniwal>
0b79e3e removing html files (1 year, 9 months ago) <Rahul Beniwal>
f2a2efe adding new files (1 year, 9 months ago) <Rahul Beniwal>
04a4dc3 adding ipynbs for xml and json parsing (1 year, 11 months ago) <Rahul Beniwal>
aa42b78 completing files and adding new categories with name data processing (1 year, 11 months ago) <Rahul Beniwal>
8190ea0 adding file2.ipynb (1 year, 11 months ago) <Rahul Beniwal>
b48a2e3 adding some new file handling methods (1 year, 11 months ago) <Rahul Beniwal>
6a552ad adding iterators and rich text ipynbs (1 year, 11 months ago) <Rahul Beniwal>
e174d5c adding iterators (1 year, 11 months ago) <Rahul Beniwal>
e83ad32 adding ipynb regarding code object in python (2 years, 2 months ago) <Rahul Beniwal>
d27641a adding ipynbs of concurrency and types (2 years, 2 months ago) <Rahul Beniwal>
879c600 adding queue (2 years, 2 months ago) <Rahul Beniwal>
b9c388a adding queue notebook (2 years, 2 months ago) <Rahul Beniwal>
7b88974 adding new ipynb for revising things (2 years, 4 months ago) <Rahul Beniwal>
10cf518 adding asyncio code example (2 years, 4 months ago) <Rahul Beniwal>
8f1b1bf Initial commit (2 years, 4 months ago) <Rahul Beniwal>
This alias provides a cleaner and more colorful log, making it easier to scan through your commit history. You can also explore other options for customizing git log to suit your needs.
Additional Git Aliases
git s for git status
git config --global alias.s 'status -sb'
This alias provides a concise summary of your working directory status.
🕙 11:21:27 ❯ git s
## master...origin/master
M a.ipynb
D data-analysis/numpy/basics.ipynb
M pydantic.ipynb
M test.txt
?? DSA/cci/
?? DSA/closest_int.py
?? DSA/count_bit.py
?? DSA/divide.py
?? DSA/graph/alien_dict_find_order.py
?? DSA/graph/course_complete.py
?? DSA/graph/detecting_cycle_in_directed_graph_bfs.py
?? DSA/graph/eventual_safe_node_bfs.py
?? DSA/graph/prerequisite_tasks.py
?? DSA/graph/revision.py
?? DSA/graph/shortest_path_in_directed_graph.py
?? DSA/graph/shortest_path_lamda_chop_foobar.py
?? DSA/graph/shortest_path_undirected_graph.py
?? DSA/graph/test.py
?? DSA/multiply.py
?? DSA/pattern/
?? DSA/power.py
git co for git checkout
git config --global alias.co 'checkout'
A shorthand for switching branches or checking out files.
Conclusion
By using git aliases, you can simplify your workflow and save valuable time. Whether you’re looking to customize your git log output or create shortcuts for common commands, these aliases will help you become more efficient in your daily Git usage.
If you found it helpful leave a 👏 and follow Rahul Beniwal
Other interesting stories by me
- Understanding the IEEE 754 Double-Precision Floating-Point Representation
- Database Sharding 101 With Python.
- Decoding Python Magic -> Overriding / and // behavior for classes.
- Better Cat For Programmers with Python.
Mastering Git log was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Rahul Beniwal
Rahul Beniwal | Sciencx (2024-07-18T14:33:54+00:00) Mastering Git log. Retrieved from https://www.scien.cx/2024/07/18/mastering-git-log/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.