GitQL (Git Query Language) is a command line tool that lets you query Git repositories using a familiar SQL-like syntax. It transforms the Git commit history into a virtual table, allowing you to filter, search, and analyze commits with simple statements like SELECT, WHERE, ORDER BY, LIMIT, etc. This tutorial shows how to install GitQL on Ubuntu 24.04.
Install GitQL
Download the archive to the /usr/local/bin
directory:
sudo wget -qO /usr/local/bin/gitql.gz https://github.com/AmrDeveloper/GQL/releases/latest/download/gql-x86_64-linux.gz
Decompress the archive to obtain the executable:
sudo gunzip /usr/local/bin/gitql.gz
Enable execution permissions on the file:
sudo chmod a+x /usr/local/bin/gitql
Use the following command to verify the installed GitQL version:
gitql --version
Testing GitQL
For testing purpose, clone the repository and navigate to it:
git clone https://github.com/AmrDeveloper/GQL && cd GQL
Once inside the repository, you can run a GitQL query to retrieve structured commit data. For example, the following command fetches the earliest 5 commits, showing their titles and timestamps in ascending order:
gitql -q "SELECT title, datetime FROM commits LIMIT 5 ORDER BY datetime ASC"
This will output something like:
╭───────────────────────────────────────────────┬─────────────────────────╮
│ title ┆ datetime │
╞═══════════════════════════════════════════════╪═════════════════════════╡
│ GQL First commit ┆ 2023-06-02 16:20:22.000 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Implement base structure and select statement ┆ 2023-06-02 18:13:58.000 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Implement limit statement ┆ 2023-06-02 18:20:43.000 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Implement offset statement ┆ 2023-06-02 18:25:52.000 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Improve the structure of GQL parser ┆ 2023-06-02 18:38:54.000 │
╰───────────────────────────────────────────────┴─────────────────────────╯
Uninstall GitQL
Remove the corresponding file to uninstall GitQL:
sudo rm -rf /usr/local/bin/gitql
Leave a Comment
Cancel reply