For more insights into GitHub commands and an extensive cheat sheet, check out our guide on GitHub Cheatsheet. Additionally, discover other must-have Git log tricks below:
Other Must-Have Git Log Tricks
Git logs are a powerful tool for tracking changes in your repository. Here are some useful Git log tricks:
- git log shows the commit history for the current branch.
- git log --follow <file> shows the commit history for a specific file, even if the file has been renamed.
- git log --grep <pattern> shows the commit history for commits with messages that match a specific pattern.
- git log -S <string> shows the commit history for commits that added or removed a specific string.
- git log --oneline shows the commit history in a condensed format.
- git log --graph shows the commit history in a graph format, with branch and merge information.
- git log --pretty=format:"%h %s" shows the commit history in a custom format.
- git log --author=<author> shows the commit history for a specific author.
- git log --since=<date> shows the commit history since a specific date.
- git log --until=<date> shows the commit history until a specific date.
- git log --oneline --decorate --all --graph shows a condensed, decorated graph of the commit history for all branches.
- git log --stat shows statistics for the number of files changed and lines added/deleted for each commit.
- git log branch1..branch2 compares the logs between two branches and shows the commits that are unique to branch2.
[Read more: Best Git Branching Strategies For Engineering Teams]
Conclusion
In conclusion, Git logs are an essential part of the Git workflow, and understanding how to use them effectively can save you time and improve your productivity. In this article, we have explored several useful Git log tricks, including limiting Git log output, and displaying Git log in a graphical format.
However, simply using Git, might not be enough to get the best out of your project space, an engineering analytics tool can equip you with the data-driven insights you need to place your team on top. Hatica offers metrics across 13 dashboards, powered by CI/CD tools, Jira, GitHub, Azure, CircleCI and GitLab. By collating tool activities at one place, Hatica helps teams streamline their workflow and improve productivity.
Subscribe to the Hatica blog today to read more about unblocking developers, and boosting productivity with engineering analytics.
FAQs
1. What is Git Log?
Git log is a command in Git that displays the commit history of a repository, including details such as author, date, and commit message.
2. How to see git logs?
Navigate to your Git repository in the terminal, and run git log -n to view the commit history and understand the changes made over time.