Reading History: log, diff, show and Navigating the Past
Project history isn't just a log—it's documentation of decisions. Learn to read history informatively: filter commits, examine changes between versions, and understand SHA-1 hashes without fear. We'll explore how to distinguish 'good history' from 'garbage history'—this directly impacts how you're perceived in a team.
- You'll be able to read repository history and quickly find the right commit by author, date, or keyword.
- You'll understand how to compare file versions at different levels: working directory, index, and commit.
- You'll learn to write commit messages following industry-standard conventions (Conventional Commits).
Simula ng leksyon
Commit History as a Project Diary
- Git log shows history as an inverted diary
- Each entry is a snapshot of changes
- Stores who changed what and when
- Allows you to see code evolution
Imagine that every time you save changes in Git, you're making an entry in a development diary. The 'git log' command shows these entries in reverse chronological order - from newest to oldest. This diary contains the complete project chronology: who made which changes and when. It's not just a list of changes, but a living history of your code's evolution. The ability to read and analyze this history is a key skill for teamwork. After all, it's through commit history that you see how the project developed, what decisions were made and why. Let's take a closer look at the structure of an individual commit.
Reading a Commit: Hash, Author, Date
- commit: unique hash identifier
- Author: who made the changes and when
- Date: commit timestamp
- Message: what exactly was changed
Look at the output of the 'git log' command. Each entry begins with a long string of characters - this is the commit hash, its unique identifier. To the right, you'll see the author of the changes and when they were made. Below that is the commit message that the developer wrote when saving the changes. Note the format: first comes the author's email in angle brackets, then the timestamp. This data helps understand the context of changes and, if necessary, contact the author for clarification. Now that we've examined the structure of a commit, let's understand what a hash is and why we need it.
#!/bin/bash
cd ~/projects/git-course/
git log -1 --pretty=format:'commit %H%nAuthor: %an <%ae>%nDate: %ad%n%n %s'
Commit Hash - Your Key to History
- A hash is a digital fingerprint of a commit
- Depends on content and metadata
- Changing even one character alters the hash
- Allows precise referencing of any version
A commit hash isn't a random string of characters but the result of a cryptographic function that transforms commit contents into a unique string. If you change even a single byte in the commit, the hash will change completely. This ensures the integrity of the change history. Knowing the hash is like having a precise bookmark - you can reference any version of the code. For example, the 'git checkout' command with a specific hash will take you to the project's state at that commit. This is particularly useful when you need to roll back changes or analyze when a bug was introduced. Now that we understand the structure of history, let's learn how to filter it - because in real projects, there can be thousands of commits.
Buong leksyon ay para sa subscription
26 pang slide sa buong bersyon.
Mabubuksan ang video, lahat ng slide, tala, pagsusulit, AI tutor, at interview pagkatapos mag-sign in at mag-subscribe.
Mag-sign in o magparehistro Mag-subscribeNilalaman ng leksyon
- Commit History as a Project Diary
- Reading a Commit: Hash, Author, Date
- Commit Hash - Your Key to History
- How to Find Commits by Author
- Filtering Commits by Date
- Searching Commit Messages
- Combining Filters
- The Problem with Reading Commit History
- Compact Display with --oneline
- Visualizing Branching with --graph
- The Full Picture with --all
- What is git diff and why do we need it?
- Comparing changes in the working directory
- What's staged for commit: git diff --staged
- Comparing Any Two Commits
- How to Examine a Specific Commit in Detail
- Practice: Examining Commit Changes
- Viewing a Specific File in a Commit
- Finding Recent Changes in a File
- Analyzing Someone Else's Code Through History
- Finding Function Introductions or Removals
- Why Commit Messages Matter
- Structure of the Perfect Commit Message
- Conventional Commits in Practice
- Refactoring Bad Commits
- Why 'Fix' Commits Are an Anti-Pattern
- Atomic Changes: One Commit, One Task
- git add -p: The Lifesaver for Clean Commits
- Summary and Assignment
Mga artikulo tungkol sa araling ito
- Mga command ng Git: cheat sheet na may mga halimbawa para sa araw-araw
- git log, diff, show, at blame: paano basahin ang history ng project sa Git
- git bisect: paano hanapin ang commit na sumira sa code
- Git at GitHub: ano ang pagkakaiba at paano sila magkaugnay
- Paano mag-install ng Git sa Windows, macOS, at Linux
Lahat ng leksyon ng kurso
- Introduction: Git from Scratch to Confident Developer
- Why Git is Essential - And Why It's a Job Requirement
- Installation and Setup: Getting Git Ready for First Use
- First Repository: init, add, commit, and the Magic of the Index
- Reading History: log, diff, show and Navigating the Past
- Branches: The Parallel Reality of Your Code
- Undoing Mistakes: restore, reset, revert — Doing It Right and the Dangers
- GitHub and Remote Repositories: Your Code in the Cloud
- Team Collaboration: Forks, Feature Branches, and Pull Requests
- Merge Conflicts: Don't Panic - Understanding and Resolving Them
- Git Workflows in Real Teams: Choosing the Right Approach
- Advanced Tools: Rebase, Stash, Cherry-pick and Tags
- Final Project: Simulating Real Team Development