For the past couple of weeks the team has been experimenting with a Show and Tell meeting on Monday afternoons, to give a high-level picture of the changes each developer has made over the last week. The idea is to briefly cover any changes you have made and focus on any tricky or non-obvious code changes. If you have a specific new Enum or fundamentally change how the routing works, we want to share this knowledge and avoid any siloing.
So the easist way to summarise what I was doing last week is to view the git log:
Err, that is too much. Let’s clean it up a bit. We don’t care about merges and I only want the last 7 days.
But that is still everyone. I need to filter only me:
Much better. Let’s add some formatting to make it a one-liner:
To prevent me having to type this command each week, we can alias it. I find it easiest to add alias commands via the editor rather than the command line, so type the following into your shell:
This will open the
.gitconfig file in your chosen editor. Add the following text into the file:
Note the use of double and single quotes, this is important for the parsing of the
.gitconfig file. The author name is also hardcoded, which is not ideal. But aliases allow
us to execute other git commands as well. The following will give us the local username for this repository.
This output can now be plugged into our main alias (using ` to escape the command)
And nothing! The author parameter now has the literal value of
git config --local user.name, which is not ideal…
The solution is to use the
! (bang) operator which tells git to execute commands in a regular shell. And since we are using the bang operator
we need to explicitly call
git when executing the
log command. The updated alias now looks like this:
This also means that the alias can be shared and used by others with no changes, making it an invaluable part of my git toolbox and one less thing for me to worry about on a weekly basis! Git aliases for the win! If you have any comments or questions, please get in touch.