{"id":311,"date":"2023-06-09T13:20:16","date_gmt":"2023-06-09T11:20:16","guid":{"rendered":"https:\/\/smolgeek.com\/?p=311"},"modified":"2023-06-09T13:35:01","modified_gmt":"2023-06-09T11:35:01","slug":"git-graph","status":"publish","type":"post","link":"https:\/\/smolgeek.com\/cs\/2023\/06\/09\/git-graph\/","title":{"rendered":"GIT &#8212; graph"},"content":{"rendered":"<p>Lately I&#8217;ve started to gravitate from GIT GUI&#8217;s tools to CLI.  <br>What I missed was graphical representation of development of ehm&#8230; development. <br>However as with most popular open source tools , there&#8217;s solution for almost everything.  <\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Simple<\/h4>\n\n\n\n<p>Just type in following command and enjoy.  Well there are few downsides but it&#8217;s simple.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git log --graph -all<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/filedn.eu\/l5hSrgny5aTmlBwoFQogJlk\/res\/pic\/post\/git_log--graph--all.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Most apparent downsides for some of us might be paging (git won&#8217;t finish \/ continue without user input in one go) and each commit taking multiple lines making even small three taking up multiple pages worth of lines.   <\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Most options<\/h4>\n\n\n\n<p>if you prefer perfectly customized output you can in fact create formatted output by going all the way of adjusting all multiple little details. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all<\/code><\/pre>\n\n\n\n<p>output<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/filedn.eu\/l5hSrgny5aTmlBwoFQogJlk\/res\/pic\/post\/git_log%20--graph--abbrev-commit--decorate--format.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Obviously it&#8217;s not for free and you might end up with pretty long command line.  You can however write it only once and then save it under global alias.  <\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Best of both worlds<\/h4>\n\n\n\n<p> And at least solution which doesn&#8217;t need 4 full lines of code but also delivers quite attractive result. Best thing is, it can be modyfied<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git log --pretty=format:\"%h %cr %s\" --graph --all<\/code><\/pre>\n\n\n\n<p>&#8211;pretty=format:&#8221;&#8230;&#8221; basically let&#8217;s you define table next to the &#8220;graphical&#8221; three.   <\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes has-tiny-font-size\"><table><thead><tr><th>Specifier<\/th><th>Description of Output<\/th><\/tr><\/thead><tbody><tr><td><code>%H<\/code><\/td><td>Commit hash<\/td><\/tr><tr><td><code>%h<\/code><\/td><td>Abbreviated commit hash<\/td><\/tr><tr><td><code>%T<\/code><\/td><td>Tree hash<\/td><\/tr><tr><td><code>%t<\/code><\/td><td>Abbreviated tree hash<\/td><\/tr><tr><td><code>%P<\/code><\/td><td>Parent hashes<\/td><\/tr><tr><td><code>%p<\/code><\/td><td>Abbreviated parent hashes<\/td><\/tr><tr><td><code>%an<\/code><\/td><td>Author name<\/td><\/tr><tr><td><code>%ae<\/code><\/td><td>Author email<\/td><\/tr><tr><td><code>%ad<\/code><\/td><td>Author date (format respects the <code>--date=option<\/code>)<\/td><\/tr><tr><td><code>%ar<\/code><\/td><td>Author date, relative<\/td><\/tr><tr><td><code>%cn<\/code><\/td><td>Committer name<\/td><\/tr><tr><td><code>%ce<\/code><\/td><td>Committer email<\/td><\/tr><tr><td><code>%cd<\/code><\/td><td>Committer date<\/td><\/tr><tr><td><code>%cr<\/code><\/td><td>Committer date, relative<\/td><\/tr><tr><td><code>%s<\/code><\/td><td>Subject<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Git-Basics-Viewing-the-Commit-History\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/git-scm.com\/book\/en\/v2\/Git-Basics-Viewing-the-Commit-History<\/a><\/figcaption><\/figure>\n\n\n\n<p>Output<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/filedn.eu\/l5hSrgny5aTmlBwoFQogJlk\/res\/pic\/post\/git_log%20--prettyformat--graph--all.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>As you can see. You get quite pleasing output with minimal code. <br> <\/p>","protected":false},"excerpt":{"rendered":"<p>Going graphical with GIT with no GUI tools using &#8211;graph command.<\/p>","protected":false},"author":1,"featured_media":321,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[3],"tags":[31],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/filedn.eu\/l5hSrgny5aTmlBwoFQogJlk\/res\/pic\/post\/git_log%20--graph--abbrev-commit--decorate--format.png","_links":{"self":[{"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/posts\/311"}],"collection":[{"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":9,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/posts\/311\/revisions\/320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/media\/321"}],"wp:attachment":[{"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smolgeek.com\/cs\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}