{"id":329140,"date":"2021-08-23T14:00:14","date_gmt":"2021-08-23T11:00:14","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-view-commit-history-with-git-log-cloudsavvy-it\/"},"modified":"2021-08-23T14:00:14","modified_gmt":"2021-08-23T11:00:14","slug":"how-to-view-commit-history-with-git-log-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-view-commit-history-with-git-log-cloudsavvy-it\/","title":{"rendered":"#How to View Commit History With Git Log \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2c60185a99d\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2c60185a99d\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-view-commit-history-with-git-log-cloudsavvy-it\/#The_Non-CLI_Solution_Just_Use_a_Git_Client\" >The Non-CLI Solution: Just Use a Git Client<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-view-commit-history-with-git-log-cloudsavvy-it\/#Using_git_log\" >Using git log<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-view-commit-history-with-git-log-cloudsavvy-it\/#Viewing_Branch_History\" >Viewing Branch History<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to View Commit History With Git Log \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-2266\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/e713ed70-1.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/e713ed70-1.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/e713ed70-1.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Git logo\" width=\"700\" height=\"299\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Git tracks commits over time, allowing you to follow the progression and history of your code. While you can always use Github online to view the public repository, navigating your local repo requires the use of CLI tools to view the Git commit history, like\u00a0<code>git log<\/code>.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"The_Non-CLI_Solution_Just_Use_a_Git_Client\"><\/span>The Non-CLI Solution: Just Use a Git Client<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>While you should definitely learn to use Git from the command line, as it helps to understand everything you\u2019re doing, this is one of the few times where it really does just make more sense to have a proper interface for viewing Git history, especially when you take into account multiple branches, remotes, tags, and contributors. The experience of using online services like GitHub is clearly beneficial, so why not have it on the desktop?<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13911\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/df2310d5.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1103\" height=\"566\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>There<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/git-scm.com\/downloads\/guis\"> are a lot of Git GUI clients out there<\/a>, but the most notable ones are <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/desktop.github.com\/\">Github Desktop<\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.gitkraken.com\/git-client\">GitKraken<\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/git-fork.com\/home\">Fork<\/a>, and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.sourcetreeapp.com\/\">SourceTree<\/a>.<\/p>\n<p>However, it\u2019s still useful to learn the commands. You might not want to use a GUI, or you may be in a remote environment over SSH, or you may just want a quick peek while you\u2019re already at your terminal. Luckily, using <code>git log<\/code>\u00a0is fairly easy.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Using_git_log\"><\/span>Using git log<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>By default, <code>git log<\/code>\u00a0shows a lot of info about each commit\u2014the ref ID, the author, the date, the commit message, and if it\u2019s the HEAD of any branches.<\/p>\n<pre>git log<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13915\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/0f313b35.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"765\" height=\"363\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you\u2019d like to know what files are affected, you\u2019ll need to run it with <code>--stat<\/code>, which will display a list of files with additions and deletions.<\/p>\n<pre>git log --stat<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13917\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/c47b0000.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1200\" height=\"434\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you\u2019d like to know what actually changed in these commits, you\u2019ll need to run it with <code>-p<\/code>, which can be used with or without <code>--stat<\/code>:<\/p>\n<pre>git log --stat -p<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13918\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/9bff64fc.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1200\" height=\"631\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This can be a lot to filter through, so you can sort by date:<\/p>\n<pre>git log --after=\"2014-7-1\" --before=\"2014-7-4\"<\/pre>\n<p>Or view by affected file:<\/p>\n<pre>git log -- example.json<\/pre>\n<p>Or with a search string:<\/p>\n<pre>git log -S\"Hello, World!\"<\/pre>\n<p>Or view important merge commits:<\/p>\n<pre>git log --merges<\/pre>\n<p>And, if you just want to view the changes of a single commit from the log, you can copy the hash and run <code>git show<\/code>:<\/p>\n<pre>git show\u00a0<!--StartFragment -->e9d802bdc3a61943b2c9c736194a202b4e000180<\/pre>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Viewing_Branch_History\"><\/span>Viewing Branch History<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Just having a list of commits can be messy to sort out branches. Luckily\u00a0<code>git log<\/code>\u00a0provides the <code>--graph<\/code>\u00a0option which can be used alongside some<\/p>\n<pre>git log --graph --oneline --decorate<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13916\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/963731e4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"835\" height=\"405\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You can also <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/mirrors.edge.kernel.org\/pub\/software\/scm\/git\/docs\/git-log.html#_pretty_formats\">use custom formatting<\/a> if you don\u2019t like the look of this:<\/p>\n<pre>--pretty=format:\"%cn committed %h on %cd\"<\/pre>\n<p>This particular set of parameters is quite useful, but there isn\u2019t a shorthand for it, so if you use this a lot, we recommend setting an alias in <code>~\/.bashrc<\/code>, or whatever equivalent config you use for your shell:<\/p>\n<pre>alias gitgraph=\"git log --graph --oneline --decorate\"<\/pre>\n<p><strong>RELATED:<\/strong> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/439736\/how-to-create-aliases-and-shell-functions-on-linux\/\"><strong><em>How to Create Aliases and Shell Functions on Linux<\/em><\/strong><\/a>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/13904\/how-to-view-commit-history-with-git-log\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to View Commit History With Git Log \u2013 CloudSavvy IT&#8221; Git tracks commits over time, allowing you to follow the progression and history of your code. While you can always use Github online to view the public repository, navigating your local repo requires the use of CLI tools to view the Git commit history,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":329141,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/e713ed70-1.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-329140","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/329140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=329140"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/329140\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/329141"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=329140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=329140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=329140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}