3 min episode 8 of 24
Today, we’ll take a look at our project’s commit history.
Git saves every commit that is ever made in the course of a project. This enables you to roll back to any earlier version at any time - even for a only a single file.
And, even more importantly, it simply allows you to understand how the project evolved.
Let’s take a look at what happened recently in our project.
The “git log” command shows us the history of commits in our project.
It lists the commits in chronological order, beginning with the newest item.
Let’s look at one of these in detail. At the bottom, you see the message that was entered for the commit. Then, there’s the time and date when it happened. And the name and email of the person that made it.
At the top, there’s the so-called “commit hash”. This is a unique identifier for the commit. In centralized version control systems like Subversion or CVS, a simple ascending revision number is used for this. However, this is simply not possible anymore in a distributed VCS like Git: The reason herefore is that, in Git, multiple people can commit their work offline, without being connected to a central server. In this scenario, you can’t say anymore whose commit is #5 und whose is #6.
In most projects, however, the first 7 characters of the hash are enough for it to be unique. So it’s safe and very common to refer to a commit using a shortened version of this 40-character monster.
The plain “git log” gives you a broad overview of recent commits. However, you can request to see more than just this kind of metadata. With the “–stat” parameter, the files that were changed are also listed.
And with the “-p” parameter, finally, you’ll even see the individual changes in detail. “P” stands for “Patch”, a synonym for the Diff of changes.
Here’s a little trick: if there’s more content available than would fit on the current page, the command line indicates this by showing a colon (“:”) at the end. Press the SPACE key to see the next page or the “q” key to quit the output.
That’s it for today. Thanks for watching - and see you in our next videos!