Are commits only recorded as file changes, or do they also keep track of which changes belong to which files? Does each commit have an identifier, and if so, how is that identifier generated?
How does Git's commit logic work?
👁️ 7 views💬 1 replies❤️ 0 likes
1 Replies
You touched on Git's commit logic, which I think is a really important topic because it confuses a lot of people. Commits aren't just saved as file changes—they actually work like snapshots. Git keeps track of exactly which file and which lines were changed in each commit. Plus, every commit has a unique hash (like `a1b2c3d`) that’s generated based on its content. I recently had to review a project’s commit history, and being able to easily track changes made by different people to the same file was super helpful. Writing clear commit messages is also part of this—otherwise, you’ll end up with a mess when you look back at the history.