I use Jekyll and GitHub Pages to build my blog. I’m usually working on different tasks simultaneously, my posts are no exception. I have several posts in progress, but they are not finished yet. That’s why I don’t want to make them public. If I will commit partially finished work, all content from
_postsdirectory will be visible for everybody. This is not what I want. But I should commit changes to pull them on another environment. The first thing I thought to put all not finished posts into another folder from which Jekyll will not generate any output. But in this case I will have a lot of boring copy-delete operations. That’s not good. Another possible solution to create a branch and store unfinished posts in it. But the easiest one is to include a line in the post from YAML Front Matter to indicate whether a post is published or not.
Variable Value Description
true/false Set to false if you don’t want a post to show up when the site is generated.
That’s it, convenient and very simple.
Not long ago I became a big fan of Git. I'm trying to understand and explore it. Not a big secret that Git stores its data inside
.gitdirectory. When you insert any content inside it, Git will give you back a key. You can use this key at the future to retrieve the content. Git objects are stored in the directory
.git/objects. Objects are named with the SHA-1 checksum of the content and its header. The subdirectory is named with the first 2 characters of the SHA-1 and the filename is the remaining 38 characters.
For better understanding of the Git objects structure I prefer to see the file system updates in real time during my actions. Well, for this purpose, we can use 2 packages: terminator and tree. Terminator allow us to check multiple GNOME terminals in one window and tree package lists contents of directories in a tree-like format.
We can open terminator, initialize an empty Git repository at test directory, divide our window into two parts and select the test directory at both parts:
$ mkdir test $ cd test $ git init Initialized empty Git repository in /tmp/test/.git/
At right window I will execute a command to refresh our window every 0.1 seconds:
$ while true; do clear; tree -a .git; sleep 0.1; done
At this and future tests directory
$ rm -rf .git/hooks
On the screenshot you can check our current situation:
Let's add some content in our Git database:
$ echo 'test commit' | git hash-object -w --stdin
We can see that at the right window after tree refresh appeared some content. That is our new object:
That's it, hope it will be helpful.
Sometimes you need to get a list of available tags from current repository. It's not a difficult task:
git tag -l v1.8.1 v1.8.1-rc0 v1.8.10 v1.8.11 v1.8.12 v1.8.2 v1.8.21 v1.8.3
But this result is not friendly for humans because of the alphanumerical sorting which was applied to this list. Readable for machines, but hard for us. In this case we can use the natural ordering which will sort list in such a way that it will make sense. You can pipe your results into the sort command and use
-Vargument which means: natural sort (version) numbers within the text:
git tag -l | sort -V v1.8.1 v1.8.1-rc0 v1.8.2 v1.8.3 v1.8.10 v1.8.11 v1.8.12 v1.8.21
If you don't want to bother yourself by typing this command every time, you can create a Git alias for it:
[alias] ... tnsort = "!git tag -l | sort -V"