{"id":3044,"date":"2011-02-18T01:23:51","date_gmt":"2011-02-17T19:53:51","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=3044"},"modified":"2016-12-19T15:29:49","modified_gmt":"2016-12-19T09:59:49","slug":"git-pretty","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/git-pretty\/","title":{"rendered":"GIT &#8211;pretty"},"content":{"rendered":"<p>git log is one of most useful commands to see information about commit , author , date and subject(comment)\u00a0 while using GIT.This displays information in blocks and hardly 5 &#8211; 7 can be listed on normal screen size. But git provides &#8211;pretty option , so that we can format the output of git log;<\/p>\n<p>Here are some ways to do that<\/p>\n<p>[shell]git log &#8211;pretty=oneline[\/shell]<\/p>\n<p>Displays just a single line log ,which includes a commit-hash and Subject(Comment).something like this<\/p>\n<blockquote>\n<pre>d1fc23c1edfd2d4ffe8ef5a873adff9321cde909 comment 3\r\na8560c814ece4e03d39164885f44e0c5cb749928 comment 2\r\ndb6195c635179b3556c41e2a974829c7e101ef51 comment 1\r\n<\/pre>\n<\/blockquote>\n<p>some other predefined options are raw,fuller,full,medium and short. Since Git is Cool we can also use some custom formats.Like<\/p>\n<p>[code]git log &#8211;pretty=format:&quot;$h&quot;[\/code]<\/p>\n<p>will give abbreviated hash of committs(Where %h defines abbreviated hash).And it would be something like<\/p>\n<blockquote>\n<pre>d1fc23c\r\na8560c8\r\ndb6195c\r\n<\/pre>\n<\/blockquote>\n<p>Which is not quite useful , to make it better lets first see other options<\/p>\n<ul>\n<li>%H\u00a0 &#8211; Commit hash<\/li>\n<li>%s\u00a0 &#8211; Subject<\/li>\n<li>%h\u00a0 &#8211; Abbreviated hash<\/li>\n<li>%an &#8211; Author name<\/li>\n<li>%ae &#8211; Author e-mail<\/li>\n<li>%ad &#8211; Author date<\/li>\n<li>%ar &#8211; Author date, relative<\/li>\n<\/ul>\n<p><\/br><br \/>\nWhile using &#8220;format&#8221; with option &#8220;&#8211;pretty&#8221; we can also specify string inside quotes.Like<\/p>\n<p>[code]git log &#8211;pretty=format:&quot;%h was committed by %an , %ar&quot;[\/code]<br \/>\nWould give something like<\/p>\n<pre><blockquote>d1fc23c was committed by hiteshBhatia , 5 months ago\r\na8560c8 was committed by hiteshBhatia , 5 months ago\r\ndb6195c was committed by hiteshBhatia , 5 months ago\r\n<\/blockquote><\/pre>\n<p>To make this more useful we can make slight changes to string passed to &#8220;format&#8221;<\/p>\n<p>[code]git log -3 &#8211;pretty=format:&quot;%h ||\u00a0 %an\u00a0 ||\u00a0\u00a0 %s\u00a0 (%ar)&quot;[\/code]<\/p>\n<p>Which will give us commit hash , author name , subject\u00a0 and relative date inside paranthesis.And -3 here is number of logs .So that his whole screen is not cluttered.This is the way I like to use it.<\/p>\n<blockquote><p>d1fc23c ||\u00a0 hiteshBhatia\u00a0 ||\u00a0\u00a0 comment 3\u00a0 (5 months ago)<br \/>\na8560c8 ||\u00a0 hiteshBhatia\u00a0 ||\u00a0\u00a0 comment 2\u00a0 (5 months ago)<br \/>\ndb6195c ||\u00a0 hiteshBhatia\u00a0 ||\u00a0\u00a0 comment 1\u00a0 (5 months ago)<\/p><\/blockquote>\n<p><\/br><br \/>\nTo explore more visit. <a href=\"http:\/\/www.kernel.org\/pub\/software\/scm\/git\/docs\/git-grep.html\">git grep manual page<\/a> or the git community book which is maintained by Scott Chacon<\/p>\n<div>_________________________________<\/div>\n<div><em>Hitesh Bhatia<\/em><br \/>\nMail,LinkedIn,<a href=\"http:\/\/www.facebook.com\/home.php?#%21\/profile.php?id=100000114437286\" target=\"_blank\">Facebook<\/a>,<a href=\"http:\/\/twitter.com\/d1_ricky\" target=\"_blank\">Twitter<\/a><br \/>\n_________________________________<\/div>\n","protected":false},"excerpt":{"rendered":"<p>git log is one of most useful commands to see information about commit , author , date and subject(comment)\u00a0 while using GIT.This displays information in blocks and hardly 5 &#8211; 7 can be listed on normal screen size. But git provides &#8211;pretty option , so that we can format the output of git log; Here [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[1],"tags":[532,530,526,375,531,528,529,527],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3044"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=3044"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3044\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=3044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=3044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=3044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}