The Command Line Way
2. Using `git log` to See Your Last 3 Commits
Alright, let's get our hands dirty with some actual commands. The powerhouse tool for viewing your commit history is, unsurprisingly, `git log`. This command can spew out your entire commit history, but we're aiming for a more focused approach. To see just the last three commits, we can use a simple modifier: `-n 3`.
So, in your terminal, navigate to your Git repository (the one you're actively working on!) and type: git log -n 3
. Hit enter, and voil! You should see a neatly formatted list of your three most recent commits, complete with their commit hashes, author information, dates, and commit messages. Its like a mini-time capsule of your coding adventures!
Now, you might be thinking, "Okay, that's cool, but it's still a bit verbose." And you'd be right! The default `git log` output includes a lot of information. Fortunately, Git provides options to customize the output format. For instance, you could use the `--pretty=oneline` flag to display each commit on a single line, making it easier to scan. Try this command: git log -n 3 --pretty=oneline
. Much cleaner, right?
The key takeaway here is that `git log` is your friend, and with a few well-placed flags, you can tailor its output to suit your specific needs. Don't be afraid to experiment with different options — the `git log` command has a wealth of customization possibilities just waiting to be discovered.