CINXE.COM
Git - Viewing the Commit History
<!DOCTYPE html> <html lang="id"> <head> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - Viewing the Commit History</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about">About</a> <ul> </ul> </li> <li> <a href="/doc" class="active">Documentation</a> <ul class="expanded"> <li> <a href="/docs">Reference</a> </li> <li> <a href="/book" class="active">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> <hr class="sidebar"> <p> This book is available in <a href="/book/en/v2/Git-Basics-Viewing-the-Commit-History">English</a>. </p> <p> Full translation available in <table> <tr><td><a href="/book/az/v2/Git%e2%80%99in-%c6%8fsaslar%c4%b1-Commit-Tarix%c3%a7%c9%99sin%c9%99-Bax%c4%b1%c5%9f">azərbaycan dili</a>,</td></tr> <tr><td><a href="/book/bg/v2/%d0%9e%d1%81%d0%bd%d0%be%d0%b2%d0%b8-%d0%bd%d0%b0-Git-%d0%9f%d1%80%d0%b5%d0%b3%d0%bb%d0%b5%d0%b4-%d0%bd%d0%b0-%d0%b8%d1%81%d1%82%d0%be%d1%80%d0%b8%d1%8f%d1%82%d0%b0-%d0%bd%d0%b0-%d0%b4%d0%b5%d0%b9%d1%81%d1%82%d0%b2%d0%b8%d1%8f%d1%82%d0%b0">български език</a>,</td></tr> <tr><td><a href="/book/de/v2/Git-Grundlagen-Anzeigen-der-Commit-Historie">Deutsch</a>,</td></tr> <tr><td><a href="/book/es/v2/Fundamentos-de-Git-Ver-el-Historial-de-Confirmaciones">Español</a>,</td></tr> <tr><td><a href="/book/fr/v2/Les-bases-de-Git-Visualiser-l%e2%80%99historique-des-validations">Français</a>,</td></tr> <tr><td><a href="/book/gr">Ελληνικά</a>,</td></tr> <tr><td><a href="/book/ja/v2/Git-%e3%81%ae%e5%9f%ba%e6%9c%ac-%e3%82%b3%e3%83%9f%e3%83%83%e3%83%88%e5%b1%a5%e6%ad%b4%e3%81%ae%e9%96%b2%e8%a6%a7">日本語</a>,</td></tr> <tr><td><a href="/book/ko/v2/Git%ec%9d%98-%ea%b8%b0%ec%b4%88-%ec%bb%a4%eb%b0%8b-%ed%9e%88%ec%8a%a4%ed%86%a0%eb%a6%ac-%ec%a1%b0%ed%9a%8c%ed%95%98%ea%b8%b0">한국어</a>,</td></tr> <tr><td><a href="/book/nl/v2/Git-Basics-De-commit-geschiedenis-bekijken">Nederlands</a>,</td></tr> <tr><td><a href="/book/ru/v2/%d0%9e%d1%81%d0%bd%d0%be%d0%b2%d1%8b-Git-%d0%9f%d1%80%d0%be%d1%81%d0%bc%d0%be%d1%82%d1%80-%d0%b8%d1%81%d1%82%d0%be%d1%80%d0%b8%d0%b8-%d0%ba%d0%be%d0%bc%d0%bc%d0%b8%d1%82%d0%be%d0%b2">Русский</a>,</td></tr> <tr><td><a href="/book/sl/v2/Osnove-Git-Pregled-zgodovine-potrditev">Slovenščina</a>,</td></tr> <tr><td><a href="/book/tl/v2/Mga-Pangunahing-Kaalaman-sa-Git-Pagtitingin-sa-Kasaysayan-ng-Commit">Tagalog</a>,</td></tr> <tr><td><a href="/book/uk/v2/%d0%9e%d1%81%d0%bd%d0%be%d0%b2%d0%b8-Git-%d0%9f%d0%b5%d1%80%d0%b5%d0%b3%d0%bb%d1%8f%d0%b4-%d1%96%d1%81%d1%82%d0%be%d1%80%d1%96%d1%97-%d0%ba%d0%be%d0%bc%d1%96%d1%82%d1%96%d0%b2">Українська</a></td></tr> <tr><td><a href="/book/zh/v2/Git-%e5%9f%ba%e7%a1%80-%e6%9f%a5%e7%9c%8b%e6%8f%90%e4%ba%a4%e5%8e%86%e5%8f%b2">简体中文</a>,</td></tr> </table> </p> <p> Partial translations available in <table> <tr><td><a href="/book/cs/v2/Z%c3%a1klady-pr%c3%a1ce-se-syst%c3%a9mem-Git-Zobrazen%c3%ad-historie-reviz%c3%ad">Čeština</a>,</td></tr> <tr><td><a href="/book/mk/v2/%d0%9e%d1%81%d0%bd%d0%be%d0%b2%d0%b8%d1%82%d0%b5-%d0%bd%d0%b0-Git-%d0%9f%d1%80%d0%b8%d0%ba%d0%b0%d0%b6%d1%83%d0%b2%d0%b0%d1%9a%d0%b5-%d0%bd%d0%b0-%d0%b8%d1%81%d1%82%d0%be%d1%80%d0%b8%d1%98%d0%b0%d1%82%d0%b0-%d0%bd%d0%b0-%d0%b8%d0%b7%d0%b2%d1%80%d1%88%d1%83%d0%b2%d0%b0%d1%9a%d0%b5">Македонски</a>,</td></tr> <tr><td><a href="/book/pl/v2/Podstawy-Gita-Podgl%c4%85d-historii-rewizji">Polski</a>,</td></tr> <tr><td><a href="/book/sr/v2/%d0%9e%d1%81%d0%bd%d0%be%d0%b2%d0%b5-%d0%bf%d1%80%d0%be%d0%b3%d1%80%d0%b0%d0%bc%d0%b0-%d0%93%d0%b8%d1%82-%d0%9f%d1%80%d0%b5%d0%b3%d0%bb%d0%b5%d0%b4-%d0%b8%d1%81%d1%82%d0%be%d1%80%d0%b8%d1%98%d0%b5-%d0%ba%d0%be%d0%bc%d0%b8%d1%82%d0%be%d0%b2%d0%b0">Српски</a>,</td></tr> <tr><td><a href="/book/uz/v2/Git-%d0%b0%d1%81%d0%be%d1%81%d0%bb%d0%b0%d1%80%d0%b8-%d0%a4%d0%b8%d0%ba%d1%81%d0%b8%d1%80%d0%bb%d0%b0%d1%88%d0%bb%d0%b0%d1%80-%d1%82%d0%b0%d1%80%d0%b8%d1%85%d0%b8%d0%bd%d0%b8-%d0%ba%d1%9e%d1%80%d0%b8%d1%88">Ўзбекча</a>,</td></tr> <tr><td><a href="/book/zh-tw/v2/Git-%e5%9f%ba%e7%a4%8e-%e6%aa%a2%e8%a6%96%e6%8f%90%e4%ba%a4%e7%9a%84%e6%ad%b7%e5%8f%b2%e8%a8%98%e9%8c%84">繁體中文</a>,</td></tr> </table> </p> <p> Translations started for <table> <tr><td><a href="/book/be/v2/Git-Basics-Viewing-the-Commit-History">Беларуская</a>,</td></tr> <tr><td><a href="/book/fa/v2/%d9%85%d9%82%d8%af%d9%85%d8%a7%d8%aa-%da%af%db%8c%d8%aa-%d8%af%db%8c%d8%af%d9%86-%d8%aa%d8%a7%d8%b1%db%8c%d8%ae%da%86%d9%87%d9%94-%da%a9%d8%a7%d9%85%db%8c%d8%aa%e2%80%8c%d9%87%d8%a7" dir="rtl">فارسی</a>,</td></tr> <tr><td><a href="/book/id/v2/Git-Basics-Viewing-the-Commit-History">Indonesian</a>,</td></tr> <tr><td><a href="/book/it/v2/Git-Basics-Viewing-the-Commit-History">Italiano</a>,</td></tr> <tr><td><a href="/book/ms/v2/Git-Basics-Viewing-the-Commit-History">Bahasa Melayu</a>,</td></tr> <tr><td><a href="/book/pt-br/v2/Fundamentos-de-Git-Vendo-o-hist%c3%b3rico-de-Commits">Português (Brasil)</a>,</td></tr> <tr><td><a href="/book/pt-pt/v2/No%c3%a7%c3%b5es-B%c3%a1sicas-do-Git-Veja-o-Hist%c3%b3rico-de-Confirma%c3%a7%c3%a3o">Português (Portugal)</a>,</td></tr> <tr><td><a href="/book/sv/v2/Grunder-i-Git-Visa-historiken">Svenska</a>,</td></tr> <tr><td><a href="/book/tr/v2/Git-Temelleri-Katk%c4%b1-Ge%c3%a7mi%c5%9fini-G%c3%b6r%c3%bcnt%c3%bcleme">Türkçe</a>.</td></tr> </table> </p> <hr class="sidebar"/> <p> The source of this book is <a href="https://github.com/progit/progit2-id">hosted on GitHub.</a></br> Patches, suggestions and comments are welcome. </p> </nav> </aside> <div id="content"> <div id="book-chapters"> <a class="dropdown-trigger" id="book-chapters-trigger" data-panel-id="chapters-dropdown" href="#">Chapters ▾</a> <div class='dropdown-panel' id='chapters-dropdown'> <div class='three-column'> <div class="column-left"> <ol class='book-toc'> <li class='chapter'> <h2>1. <a href="/book/id/v2/Memulai-Tentang-Version-Control">Memulai</a></h2> <ol> <li> 1.1 <a href="/book/id/v2/Memulai-Tentang-Version-Control">Tentang Version Control</a> </li> <li> 1.2 <a href="/book/id/v2/Memulai-Sejarah-Singkat-Git">Sejarah Singkat Git</a> </li> <li> 1.3 <a href="/book/id/v2/Memulai-Dasar-dasar-Git">Dasar-dasar Git</a> </li> <li> 1.4 <a href="/book/id/v2/Memulai-Command-Line">Command Line</a> </li> <li> 1.5 <a href="/book/id/v2/Memulai-Memasang-Git">Memasang Git</a> </li> <li> 1.6 <a href="/book/id/v2/Memulai-Pengaturan-Awal-Git">Pengaturan Awal Git</a> </li> <li> 1.7 <a href="/book/id/v2/Memulai-Mendapatkan-Bantuan">Mendapatkan Bantuan</a> </li> <li> 1.8 <a href="/book/id/v2/Memulai-Kesimpulan">Kesimpulan</a> </li> </ol> </li> <li class='chapter'> <h2>2. <a href="/book/id/v2/Git-Basics-Mendapatkan-Repository-Git">Git Basics</a></h2> <ol> <li> 2.1 <a href="/book/id/v2/Git-Basics-Mendapatkan-Repository-Git">Mendapatkan Repository Git</a> </li> <li> 2.2 <a href="/book/id/v2/Git-Basics-Recording-Changes-to-the-Repository">Recording Changes to the Repository</a> </li> <li> 2.3 <a href="/book/id/v2/Git-Basics-Viewing-the-Commit-History" class="active">Viewing the Commit History</a> </li> <li> 2.4 <a href="/book/id/v2/Git-Basics-Undoing-Things">Undoing Things</a> </li> <li> 2.5 <a href="/book/id/v2/Git-Basics-Working-with-Remotes">Working with Remotes</a> </li> <li> 2.6 <a href="/book/id/v2/Git-Basics-Tagging">Tagging</a> </li> <li> 2.7 <a href="/book/id/v2/Git-Basics-Alias-Git">Alias Git</a> </li> <li> 2.8 <a href="/book/id/v2/Git-Basics-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>3. <a href="/book/id/v2/Git-Branching-Branches-in-a-Nutshell">Git Branching</a></h2> <ol> <li> 3.1 <a href="/book/id/v2/Git-Branching-Branches-in-a-Nutshell">Branches in a Nutshell</a> </li> <li> 3.2 <a href="/book/id/v2/Git-Branching-Basic-Branching-and-Merging">Basic Branching and Merging</a> </li> <li> 3.3 <a href="/book/id/v2/Git-Branching-Branch-Management">Branch Management</a> </li> <li> 3.4 <a href="/book/id/v2/Git-Branching-Branching-Workflows">Branching Workflows</a> </li> <li> 3.5 <a href="/book/id/v2/Git-Branching-Remote-Branches">Remote Branches</a> </li> <li> 3.6 <a href="/book/id/v2/Git-Branching-Rebasing">Rebasing</a> </li> <li> 3.7 <a href="/book/id/v2/Git-Branching-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>4. <a href="/book/id/v2/Git-di-Server-Protokol">Git di Server</a></h2> <ol> <li> 4.1 <a href="/book/id/v2/Git-di-Server-Protokol">Protokol</a> </li> <li> 4.2 <a href="/book/id/v2/Git-di-Server-Getting-Git-on-a-Server">Getting Git on a Server</a> </li> <li> 4.3 <a href="/book/id/v2/Git-di-Server-Generating-Your-SSH-Public-Key">Generating Your SSH Public Key</a> </li> <li> 4.4 <a href="/book/id/v2/Git-di-Server-Setting-Up-the-Server">Setting Up the Server</a> </li> <li> 4.5 <a href="/book/id/v2/Git-di-Server-Git-Daemon">Git Daemon</a> </li> <li> 4.6 <a href="/book/id/v2/Git-di-Server-Smart-HTTP">Smart HTTP</a> </li> <li> 4.7 <a href="/book/id/v2/Git-di-Server-GitWeb">GitWeb</a> </li> <li> 4.8 <a href="/book/id/v2/Git-di-Server-GitLab">GitLab</a> </li> <li> 4.9 <a href="/book/id/v2/Git-di-Server-Third-Party-Hosted-Options">Third Party Hosted Options</a> </li> <li> 4.10 <a href="/book/id/v2/Git-di-Server-Ringkasan">Ringkasan</a> </li> </ol> </li> <li class='chapter'> <h2>5. <a href="/book/id/v2/Distributed-Git-Distributed-Workflows">Distributed Git</a></h2> <ol> <li> 5.1 <a href="/book/id/v2/Distributed-Git-Distributed-Workflows">Distributed Workflows</a> </li> <li> 5.2 <a href="/book/id/v2/Distributed-Git-Contributing-to-a-Project">Contributing to a Project</a> </li> <li> 5.3 <a href="/book/id/v2/Distributed-Git-Maintaining-a-Project">Maintaining a Project</a> </li> <li> 5.4 <a href="/book/id/v2/Distributed-Git-Summary">Summary</a> </li> </ol> </li> </ol> </div> <div class='column-middle'> <ol class='book-toc'> <li class='chapter'> <h2>6. <a href="/book/id/v2/GitHub-Pengaturan-dan-Konfigurasi-Akun">GitHub</a></h2> <ol> <li> 6.1 <a href="/book/id/v2/GitHub-Pengaturan-dan-Konfigurasi-Akun">Pengaturan dan Konfigurasi Akun</a> </li> <li> 6.2 <a href="/book/id/v2/GitHub-Contributing-to-a-Project">Contributing to a Project</a> </li> <li> 6.3 <a href="/book/id/v2/GitHub-Maintaining-a-Project">Maintaining a Project</a> </li> <li> 6.4 <a href="/book/id/v2/GitHub-Mengelola-Organization">Mengelola Organization</a> </li> <li> 6.5 <a href="/book/id/v2/GitHub-Scripting-GitHub">Scripting GitHub</a> </li> <li> 6.6 <a href="/book/id/v2/GitHub-Ringkasan">Ringkasan</a> </li> </ol> </li> <li class='chapter'> <h2>7. <a href="/book/id/v2/Git-Tools-Revision-Selection">Git Tools</a></h2> <ol> <li> 7.1 <a href="/book/id/v2/Git-Tools-Revision-Selection">Revision Selection</a> </li> <li> 7.2 <a href="/book/id/v2/Git-Tools-Interactive-Staging">Interactive Staging</a> </li> <li> 7.3 <a href="/book/id/v2/Git-Tools-Stashing-and-Cleaning">Stashing and Cleaning</a> </li> <li> 7.4 <a href="/book/id/v2/Git-Tools-Signing-Your-Work">Signing Your Work</a> </li> <li> 7.5 <a href="/book/id/v2/Git-Tools-Searching">Searching</a> </li> <li> 7.6 <a href="/book/id/v2/Git-Tools-Rewriting-History">Rewriting History</a> </li> <li> 7.7 <a href="/book/id/v2/Git-Tools-Reset-Demystified">Reset Demystified</a> </li> <li> 7.8 <a href="/book/id/v2/Git-Tools-Advanced-Merging">Advanced Merging</a> </li> <li> 7.9 <a href="/book/id/v2/Git-Tools-Rerere">Rerere</a> </li> <li> 7.10 <a href="/book/id/v2/Git-Tools-Debugging-with-Git">Debugging with Git</a> </li> <li> 7.11 <a href="/book/id/v2/Git-Tools-Submodules">Submodules</a> </li> <li> 7.12 <a href="/book/id/v2/Git-Tools-Bundling">Bundling</a> </li> <li> 7.13 <a href="/book/id/v2/Git-Tools-Replace">Replace</a> </li> <li> 7.14 <a href="/book/id/v2/Git-Tools-Credential-Storage">Credential Storage</a> </li> <li> 7.15 <a href="/book/id/v2/Git-Tools-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>8. <a href="/book/id/v2/Kostumisasi-Git-Konfigurasi-Git">Kostumisasi Git</a></h2> <ol> <li> 8.1 <a href="/book/id/v2/Kostumisasi-Git-Konfigurasi-Git">Konfigurasi Git</a> </li> <li> 8.2 <a href="/book/id/v2/Kostumisasi-Git-Git-Attributes">Git Attributes</a> </li> <li> 8.3 <a href="/book/id/v2/Kostumisasi-Git-Git-Hooks">Git Hooks</a> </li> <li> 8.4 <a href="/book/id/v2/Kostumisasi-Git-An-Example-Git-Enforced-Policy">An Example Git-Enforced Policy</a> </li> <li> 8.5 <a href="/book/id/v2/Kostumisasi-Git-Ringkasan">Ringkasan</a> </li> </ol> </li> <li class='chapter'> <h2>9. <a href="/book/id/v2/Git-and-Other-Systems-Git-as-a-Client">Git and Other Systems</a></h2> <ol> <li> 9.1 <a href="/book/id/v2/Git-and-Other-Systems-Git-as-a-Client">Git as a Client</a> </li> <li> 9.2 <a href="/book/id/v2/Git-and-Other-Systems-Migrating-to-Git">Migrating to Git</a> </li> <li> 9.3 <a href="/book/id/v2/Git-and-Other-Systems-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>10. <a href="/book/id/v2/Git-Internals-Plumbing-and-Porcelain">Git Internals</a></h2> <ol> <li> 10.1 <a href="/book/id/v2/Git-Internals-Plumbing-and-Porcelain">Plumbing and Porcelain</a> </li> <li> 10.2 <a href="/book/id/v2/Git-Internals-Git-Objects">Git Objects</a> </li> <li> 10.3 <a href="/book/id/v2/Git-Internals-Git-References">Git References</a> </li> <li> 10.4 <a href="/book/id/v2/Git-Internals-Packfiles">Packfiles</a> </li> <li> 10.5 <a href="/book/id/v2/Git-Internals-The-Refspec">The Refspec</a> </li> <li> 10.6 <a href="/book/id/v2/Git-Internals-Transfer-Protocols">Transfer Protocols</a> </li> <li> 10.7 <a href="/book/id/v2/Git-Internals-Maintenance-and-Data-Recovery">Maintenance and Data Recovery</a> </li> <li> 10.8 <a href="/book/id/v2/Git-Internals-Environment-Variables">Environment Variables</a> </li> <li> 10.9 <a href="/book/id/v2/Git-Internals-Summary">Summary</a> </li> </ol> </li> </ol> </div> <div class='column-right'> <ol class='book-toc'> <li class='chapter'> <h2>A1. <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Graphical-Interfaces">Appendix A: Git in Other Environments</a></h2> <ol> <li> A1.1 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Graphical-Interfaces">Graphical Interfaces</a> </li> <li> A1.2 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Visual-Studio">Git in Visual Studio</a> </li> <li> A1.3 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Eclipse">Git in Eclipse</a> </li> <li> A1.4 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Bash">Git in Bash</a> </li> <li> A1.5 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Zsh">Git in Zsh</a> </li> <li> A1.6 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Powershell">Git in Powershell</a> </li> <li> A1.7 <a href="/book/id/v2/Appendix-A:-Git-in-Other-Environments-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>A2. <a href="/book/id/v2/Appendix-B:-Embedding-Git-in-your-Applications-Command-line-Git">Appendix B: Embedding Git in your Applications</a></h2> <ol> <li> A2.1 <a href="/book/id/v2/Appendix-B:-Embedding-Git-in-your-Applications-Command-line-Git">Command-line Git</a> </li> <li> A2.2 <a href="/book/id/v2/Appendix-B:-Embedding-Git-in-your-Applications-Libgit2">Libgit2</a> </li> <li> A2.3 <a href="/book/id/v2/Appendix-B:-Embedding-Git-in-your-Applications-JGit">JGit</a> </li> </ol> </li> <li class='chapter'> <h2>A3. <a href="/book/id/v2/Appendix-C:-Git-Commands-Setup-and-Config">Appendix C: Git Commands</a></h2> <ol> <li> A3.1 <a href="/book/id/v2/Appendix-C:-Git-Commands-Setup-and-Config">Setup and Config</a> </li> <li> A3.2 <a href="/book/id/v2/Appendix-C:-Git-Commands-Getting-and-Creating-Projects">Getting and Creating Projects</a> </li> <li> A3.3 <a href="/book/id/v2/Appendix-C:-Git-Commands-Basic-Snapshotting">Basic Snapshotting</a> </li> <li> A3.4 <a href="/book/id/v2/Appendix-C:-Git-Commands-Branching-and-Merging">Branching and Merging</a> </li> <li> A3.5 <a href="/book/id/v2/Appendix-C:-Git-Commands-Sharing-and-Updating-Projects">Sharing and Updating Projects</a> </li> <li> A3.6 <a href="/book/id/v2/Appendix-C:-Git-Commands-Inspection-and-Comparison">Inspection and Comparison</a> </li> <li> A3.7 <a href="/book/id/v2/Appendix-C:-Git-Commands-Debugging">Debugging</a> </li> <li> A3.8 <a href="/book/id/v2/Appendix-C:-Git-Commands-Patching">Patching</a> </li> <li> A3.9 <a href="/book/id/v2/Appendix-C:-Git-Commands-Email">Email</a> </li> <li> A3.10 <a href="/book/id/v2/Appendix-C:-Git-Commands-External-Systems">External Systems</a> </li> <li> A3.11 <a href="/book/id/v2/Appendix-C:-Git-Commands-Administration">Administration</a> </li> <li> A3.12 <a href="/book/id/v2/Appendix-C:-Git-Commands-Plumbing-Commands">Plumbing Commands</a> </li> </ol> </li> </ol> </div> </div> </div> <span class="light" id="edition"> 2nd Edition </span> </div> <div id="main" data-pagefind-filter="category:book" data-pagefind-meta="category:Book" data-pagefind-weight="0.05" data-pagefind-body class="book edition2"> <h1>2.3 Git Basics - Viewing the Commit History</h1> <div> <h2 id="_viewing_history">Viewing the Commit History</h2> <div class="paragraph"> <p>After you have created several commits, or if you have cloned a repository with an existing commit history, you’ll probably want to look back to see what has happened. The most basic and powerful tool to do this is the <code>git log</code> command.</p> </div> <div class="paragraph"> <p>These examples use a very simple project called “simplegit”. To get the project, run</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">git clone https://github.com/schacon/simplegit-progit</code></pre> </div> </div> <div class="paragraph"> <p>When you run <code>git log</code> in this project, you should get output that looks something like this:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test commit a11bef06a3f659402fe7563abf99ad00de2209e6 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 10:31:28 2008 -0700 first commit</code></pre> </div> </div> <div class="paragraph"> <p>By default, with no arguments, <code>git log</code> lists the commits made in that repository in reverse chronological order – that is, the most recent commits show up first. As you can see, this command lists each commit with its SHA-1 checksum, the author’s name and e-mail, the date written, and the commit message.</p> </div> <div class="paragraph"> <p>A huge number and variety of options to the <code>git log</code> command are available to show you exactly what you’re looking for. Here, we’ll show you some of the most popular.</p> </div> <div class="paragraph"> <p>One of the more helpful options is <code>-p</code>, which shows the difference introduced in each commit. You can also use <code>-2</code>, which limits the output to only the last two entries:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log -p -2 commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number diff --git a/Rakefile b/Rakefile index a874b73..8f94139 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "simplegit" - s.version = "0.1.0" + s.version = "0.1.1" s.author = "Scott Chacon" s.email = "schacon@gee-mail.com" s.summary = "A simple gem for using Git in Ruby code." commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test diff --git a/lib/simplegit.rb b/lib/simplegit.rb index a0a60ae..47c6340 100644 --- a/lib/simplegit.rb +++ b/lib/simplegit.rb @@ -18,8 +18,3 @@ class SimpleGit end end - -if $0 == __FILE__ - git = SimpleGit.new - puts git.show -end \ No newline at end of file</code></pre> </div> </div> <div class="paragraph"> <p>This option displays the same information but with a diff directly following each entry. This is very helpful for code review or to quickly browse what happened during a series of commits that a collaborator has added. You can also use a series of summarizing options with <code>git log</code>. For example, if you want to see some abbreviated stats for each commit, you can use the <code>--stat</code> option:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log --stat commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test lib/simplegit.rb | 5 ----- 1 file changed, 5 deletions(-) commit a11bef06a3f659402fe7563abf99ad00de2209e6 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 10:31:28 2008 -0700 first commit README | 6 ++++++ Rakefile | 23 +++++++++++++++++++++++ lib/simplegit.rb | 25 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+)</code></pre> </div> </div> <div class="paragraph"> <p>As you can see, the <code>--stat</code> option prints below each commit entry a list of modified files, how many files were changed, and how many lines in those files were added and removed. It also puts a summary of the information at the end.</p> </div> <div class="paragraph"> <p>Another really useful option is <code>--pretty</code>. This option changes the log output to formats other than the default. A few prebuilt options are available for you to use. The <code>oneline</code> option prints each commit on a single line, which is useful if you’re looking at a lot of commits. In addition, the <code>short</code>, <code>full</code>, and <code>fuller</code> options show the output in roughly the same format but with less or more information, respectively:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log --pretty=oneline ca82a6dff817ec66f44342007202690a93763949 changed the version number 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test a11bef06a3f659402fe7563abf99ad00de2209e6 first commit</code></pre> </div> </div> <div class="paragraph"> <p>The most interesting option is <code>format</code>, which allows you to specify your own log output format. This is especially useful when you’re generating output for machine parsing – because you specify the format explicitly, you know it won’t change with updates to Git:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log --pretty=format:"%h - %an, %ar : %s" ca82a6d - Scott Chacon, 6 years ago : changed the version number 085bb3b - Scott Chacon, 6 years ago : removed unnecessary test a11bef0 - Scott Chacon, 6 years ago : first commit</code></pre> </div> </div> <div class="paragraph"> <p><a href="/book/id/v2/ch00/pretty_format">Useful options for <code>git log --pretty=format</code></a> lists some of the more useful options that format takes.</p> </div> <table id="pretty_format" class="tableblock frame-all grid-all stretch"> <caption class="title">Table 1. Useful options for <code>git log --pretty=format</code> </caption> <colgroup> <col style="width: 20%;"> <col style="width: 80%;"> </colgroup> <thead> <tr> <th class="tableblock halign-left valign-top">Option</th> <th class="tableblock halign-left valign-top">Description of Output</th> </tr> </thead> <tbody> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%H</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Commit hash</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%h</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Abbreviated commit hash</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%T</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Tree hash</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%t</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Abbreviated tree hash</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%P</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Parent hashes</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%p</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Abbreviated parent hashes</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%an</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Author name</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%ae</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Author e-mail</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%ad</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Author date (format respects the –date= option)</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%ar</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Author date, relative</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%cn</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Committer name</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%ce</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Committer email</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%cd</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Committer date</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%cr</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Committer date, relative</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>%s</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Subject</p></td> </tr> </tbody> </table> <div class="paragraph"> <p>You may be wondering what the difference is between <em>author</em> and <em>committer</em>. The author is the person who originally wrote the work, whereas the committer is the person who last applied the work. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit – you as the author, and the core member as the committer. We’ll cover this distinction a bit more in <a href="/book/id/v2/ch00/_distributed_git">Distributed Git</a>.</p> </div> <div class="paragraph"> <p>The oneline and format options are particularly useful with another <code>log</code> option called <code>--graph</code>. This option adds a nice little ASCII graph showing your branch and merge history:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log --pretty=format:"%h %s" --graph * 2d3acf9 ignore errors from SIGCHLD on trap * 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit |\ | * 420eac9 Added a method for getting the current branch. * | 30e367c timeout code and tests * | 5a09431 add timeout protection to grit * | e1193f8 support for heads with slashes in them |/ * d6016bc require time for xmlschema * 11d191e Merge branch 'defunkt' into local</code></pre> </div> </div> <div class="paragraph"> <p>This type of output will become more interesting as we go through branching and merging in the next chapter.</p> </div> <div class="paragraph"> <p>Those are only some simple output-formatting options to <code>git log</code> – there are many more. <a href="/book/id/v2/ch00/log_options">Common options to <code>git log</code></a> lists the options we’ve covered so far, as well as some other common formatting options that may be useful, along with how they change the output of the log command.</p> </div> <table id="log_options" class="tableblock frame-all grid-all stretch"> <caption class="title">Table 2. Common options to <code>git log</code> </caption> <colgroup> <col style="width: 20%;"> <col style="width: 80%;"> </colgroup> <thead> <tr> <th class="tableblock halign-left valign-top">Option</th> <th class="tableblock halign-left valign-top">Description</th> </tr> </thead> <tbody> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>-p</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show the patch introduced with each commit.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--stat</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show statistics for files modified in each commit.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--shortstat</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Display only the changed/insertions/deletions line from the --stat command.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--name-only</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show the list of files modified after the commit information.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--name-status</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show the list of files affected with added/modified/deleted information as well.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--abbrev-commit</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show only the first few characters of the SHA-1 checksum instead of all 40.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--relative-date</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--graph</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Display an ASCII graph of the branch and merge history beside the log output.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--pretty</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).</p></td> </tr> </tbody> </table> <div class="sect3"> <h3 id="_limiting_log_output">Limiting Log Output</h3> <div class="paragraph"> <p>In addition to output-formatting options, <code>git log</code> takes a number of useful limiting options – that is, options that let you show only a subset of commits. You’ve seen one such option already – the <code>-2</code> option, which show only the last two commits. In fact, you can do <code>-<n></code>, where <code>n</code> is any integer to show the last <code>n</code> commits. In reality, you’re unlikely to use that often, because Git by default pipes all output through a pager so you see only one page of log output at a time.</p> </div> <div class="paragraph"> <p>However, the time-limiting options such as <code>--since</code> and <code>--until</code> are very useful. For example, this command gets the list of commits made in the last two weeks:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log --since=2.weeks</code></pre> </div> </div> <div class="paragraph"> <p>This command works with lots of formats – you can specify a specific date like <code>"2008-01-15"</code>, or a relative date such as <code>"2 years 1 day 3 minutes ago"</code>.</p> </div> <div class="paragraph"> <p>You can also filter the list to commits that match some search criteria. The <code>--author</code> option allows you to filter on a specific author, and the <code>--grep</code> option lets you search for keywords in the commit messages. (Note that if you want to specify both author and grep options, you have to add <code>--all-match</code> or the command will match commits with either.)</p> </div> <div class="paragraph"> <p>Another really helpful filter is the <code>-S</code> option which takes a string and only shows the commits that introduced a change to the code that added or removed that string. For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log -Sfunction_name</code></pre> </div> </div> <div class="paragraph"> <p>The last really useful option to pass to <code>git log</code> as a filter is a path. If you specify a directory or file name, you can limit the log output to commits that introduced a change to those files. This is always the last option and is generally preceded by double dashes (<code>--</code>) to separate the paths from the options.</p> </div> <div class="paragraph"> <p>In <a href="/book/id/v2/ch00/limit_options">Options to limit the output of <code>git log</code></a> we’ll list these and a few other common options for your reference.</p> </div> <table id="limit_options" class="tableblock frame-all grid-all stretch"> <caption class="title">Table 3. Options to limit the output of <code>git log</code> </caption> <colgroup> <col style="width: 33.3333%;"> <col style="width: 66.6667%;"> </colgroup> <thead> <tr> <th class="tableblock halign-left valign-top">Option</th> <th class="tableblock halign-left valign-top">Description</th> </tr> </thead> <tbody> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>-(n)</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Show only the last n commits</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--since</code>, <code>--after</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Limit the commits to those made after the specified date.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--until</code>, <code>--before</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Limit the commits to those made before the specified date.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--author</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Only show commits in which the author entry matches the specified string.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--committer</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Only show commits in which the committer entry matches the specified string.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>--grep</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Only show commits with a commit message containing the string</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock"><code>-S</code></p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Only show commits adding or removing code matching the string</p></td> </tr> </tbody> </table> <div class="paragraph"> <p>For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano and were not merges in the month of October 2008, you can run something like this:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ git log --pretty="%h - %s" --author=gitster --since="2008-10-01" \ --before="2008-11-01" --no-merges -- t/ 5610e3b - Fix testcase failure when extended attributes are in use acd3b9e - Enhance hold_lock_file_for_{update,append}() API f563754 - demonstrate breakage of detached checkout with symbolic link HEAD d1a43f2 - reset --hard/read-tree --reset -u: remove unmerged new paths 51a94af - Fix "checkout --track -b newbranch" on detached HEAD b0ad11e - pull: allow "git pull origin $something:$current_branch" into an unborn branch</code></pre> </div> </div> <div class="paragraph"> <p>Of the nearly 40,000 commits in the Git source code history, this command shows the 6 that match those criteria.</p> </div> </div> <div id="nav"><a href="/book/id/v2/Git-Basics-Recording-Changes-to-the-Repository">prev</a> | <a href="/book/id/v2/Git-Basics-Undoing-Things">next</a></div> </div> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/application.min.js"></script> </div> </body> </html>