Introduction
🧑💻 New to Git or LabEx? We recommend starting with the Quick Start with Git course.
Git is a popular version control system that allows developers to track changes in their codebase. One of the essential features of Git is the ability to view the last commit made to a repository. In this challenge, you will learn how to view the last commit made to a Git repository.
View Last Commit
You are working on a project with a team of developers, and you need to view the last commit made to the project's Git repository. You want to see the details of the commit, including the commit message, author, and date.
To view the last commit made to a Git repository, follow these steps:
- Open the terminal on your computer.
- Navigate to the directory where the Git repository is located:
cd git-playground
- View the last commit:
git log -1
The output will show you the details of the last commit, including the commit message, author, and date:
commit d22f46ba8c2d4e07d773c5126e9c803933eb5898 (HEAD -> master, origin/master, origin/feature-branch, origin/HEAD)
Author: Hang <huhuhang@users.noreply.github.com>
Date: Wed Apr 26 14:16:25 2023 +0800
Added file2.txt
Summary
Viewing the last commit made to a Git repository is a simple process that can provide valuable information about the project's history. By using the git log -1 command, you can see the details of the last commit, including the commit message, author, and date.