In my work at Futurice I have started a small tradition in my team that we call the Git Tip Of The Day. Each day I share a small feature of git that might not be known to everybody but that can help people in their daily work. I will start sharing some of these here on the blog as well. Of course, most of these have been featured in other blogs before but I find that it often helps to get another perspective on a topic.
So on this happy Tuesday I will talk about a feature that can come in quite handy in daily standups at the beginning of the week. A command that will help you answer the question “what did I work on last Friday again?”
git log --all --since='last Friday' --author='knut'
You probably know already that you can use
git log to look at commits in a git repository. In the example above I am passing three flags that you might not have used before.
--allmakes sure to consider all branches in the log. This is helpful if you can’t even remember on what branch you made your changes.
--sincesets a start time from which on dates should be considered. Git uses a custom and very flexible date parser here that is internally known as
approxidate. You can provide dates such as
2019-01-01but also relative dates like
2 weeks ago,
yesterday, etc. Unfortunately, the accepted formats seems not to be documented very well.
--sincealso a sibling command called
-- authortakes a
patternargument which it will match against the author of the commit message. This means that since I am the only Knut in my project I can simply filter by my name here. If there were multiple, I would probably provide my email address
If you only want to get a quick overview and do not care about the commit message bodies you can also add a
--oneline to the end of the command to get a condensed list.
If you cannot be bothered remembering all of this, there is also git-standup, a wrapper around
git log which simplifies this whole process. I personally find
git log to be good enough though especially since it does not require any extra installs.
Is there an option to
git log I missed? Or another feature of git that you would like to learn more about? Let me know on twitter.