Clik here to view.

I was looking for an easy way to get some kind of work journal. What I wanted was a quick way to log small entries, with a timestamp.
I thought about simply using a text file, but then I still had to add a date and time every time. There are ways to automated that, but still, it’s a bit tedious or too much of a hassle to set up.
Then I thought, why not use Git’s commit log for this? It has everything I want. I can write messages (commit message), which automatically get a timestamp. Easy-peasy. I can afterward use git log
to query them, and even reformat the output if I want to. Sounds perfect right?
To get started, we need a place for our Git repository that will store our journal entries. So let’s create a directory, and initialize it as a Git repository:
md worklog
cd worklog
git init
Okay, that’s settled then. Now, how do I add a journal entry without actually having to commit a file? We use the --allow-empty
command line switch for that.
git commit --allow-empty -m "Today was a good day."
Or if you’d rather use Vim to edit a more elaborate commit message, you simply use:
git commit --allow-empty
Since that’s a pain to type, this goes into a batch script with a shorter name, so you can run it by typing just a few letters.
To get the log data for the last 5 entries, you use something like this:
cd worklog
git log -n 5
Again, this goes into a script or macro called “wl” oslt, so you can access it real fast.
More complex log queries are also possible. Just check the Git log documentation for more options.
You can now even push your journal to GitHub or GitLab if you want to sync on multiple machines. Endless possibilities!
The post using git for journaling appeared first on n3wjack's blog.