Git's git-log package offers some powerful options for surfing through our commit histories.
We can use the default git log
command to view the past five commits:
git log
But viewing five commits at a time is not very efficient, especially in larger and more active repositories.
We can pass oneline
to the --pretty
flag to print several more commits to the console, with each commit occupying just one line each:
git log --pretty=oneline
Using the --pretty
flag will open an interface where you can use the up and down arrow keys to scroll through your commits.
To quit this interface, press the Q key.
Anyway, if you don't need to see the full commit hash on each line, I'd recommend this cleaner alternative which just displays an abbreviaton of the full hash on each line to save space:
git log --oneline --decorate
Also, if you're working with lots of branches, throwing in the --graph
flag might help you visualize them a bit better:
git log --oneline --decorate --graph
Conclusion
While this article has hardly scratched the surface of what you can do with passing options to git log
, I hope these commands help you skim throguh your commits more productively!
Top comments (0)