{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/github-logs","result":{"data":{"markdownRemark":{"html":"<h2>Github immersion</h2>\n<p>I decided to spend the day learning github more in depth. One of my favourite resources is <a href=\"http://gitimmersion.com/\">GithubImmersion</a>.\nIt can get intimidating to practice your work with a language you never really use (ruby), but I am getting less scared of trying new things and I just created the file to play around with. </p>\n<p>One of the most interesting things that I have yet to add to my workflow, is <code class=\"language-text\">git log</code>\nGetting a listing of what changes have been made is the function of the git log command.</p>\n<p>There are a lot of options for selecting which entries are displayed in the log.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">$ git log --pretty=oneline --max-count=2\n$ git log --pretty=oneline --since=&#39;5 minutes ago&#39;\n$ git log --pretty=oneline --until=&#39;5 minutes ago&#39;\n$ git log --pretty=oneline --author=&lt;your name&gt;\n$ git log --pretty=oneline --all</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Here is a great log format that you can use for your own logs:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">$ git log --pretty=format:&#39;%h %ad | %s%d [%an]&#39; --graph --date=short</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>It should output something like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\"> 6118034 2020-01-31 | added comment (HEAD -&gt; master) [lalawuhan]\n 525466d 2020-01-31 | added a default value [lalawuhan]\n b4cf229 2020-01-31 | Using Argv       # [lalawuhan]\n 136ac2f 2020-01-31 | first [lalawuhan]</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>This is what it consists of: </p>\n<ul>\n<li><code class=\"language-text\">--pretty=&quot;...&quot;</code> defines the format of the output.</li>\n<li><code class=\"language-text\">%h</code> is the abbreviated hash of the commit</li>\n<li><code class=\"language-text\">%d</code> are any decorations on that commit (e.g. branch heads or tags)</li>\n<li><code class=\"language-text\">%ad</code> is the author date</li>\n<li><code class=\"language-text\">%s</code> is the comment</li>\n<li><code class=\"language-text\">%an</code> is the author name</li>\n<li><code class=\"language-text\">--graph</code> informs git to display the commit tree in an ASCII graph layout</li>\n<li><code class=\"language-text\">--date=short</code> keeps the date format nice and short</li>\n</ul>\n<h3>Other Tools</h3>\n<p>Both gitx (for Macs) and gitk (any platform) are useful in exploring log history.</p>\n<h3>Common Shortcuts</h3>\n<p><code class=\"language-text\">git status</code>, <code class=\"language-text\">git add</code>, <code class=\"language-text\">git commit</code>, and <code class=\"language-text\">git checkout</code> are such common commands that it is useful to have abbreviations for them.</p>\n<p>Add the following to the .gitconfig file in your $HOME directory.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">.gitconfig\n[alias]\n  co = checkout\n  ci = commit\n  st = status\n  br = branch\n  hist = log --pretty=format:&#39;%h %ad | %s%d [%an]&#39; --graph --date=short\n  type = cat-file -t\n  dump = cat-file -p</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>","excerpt":"Github immersion I decided to spend the day learning github more in depth. One of my favourite resources is GithubImmersion.\nIt can get intimidating to practice…","frontmatter":{"date":"31 January, 2020","path":"/blog/github-logs","title":"Github logging"},"fields":{"readingTime":{"text":"2 min read"}}}},"pageContext":{}}}