๐งโ๐ป New to Git or LabEx? We recommend starting with the Quick Start with Git course.
Git is a popular version control system used by developers to manage their code changes. One of the essential features of Git is the ability to create commits, which are snapshots of the code at a particular point in time. In this lab, you will learn how to create a Git commit.
You have made some changes to your code and want to save them as a snapshot in your Git repository. However, you don't want to save all the changes you made, only the ones that are relevant to the current feature or bug fix. How can you create a commit containing only the relevant changes?
For this lab, let's use the repository from https://github.com/labex-labs/git-playground, follow these steps:
Clone the repository and navigate it:
git clone https://github.com/labex-labs/git-playground
cd git-playground
The -m option allows you to specify a commit message. Make sure the message is descriptive and explains what changes the commit contains.
This is the result of running the git log command:
Summary
Creating a Git commit is an essential part of the development process. It allows you to save snapshots of your code and keep track of the changes you make over time. By following the steps outlined in this lab, you can create a commit containing only the relevant changes and add a descriptive message to explain the changes made.
We use cookies for a number of reasons, such as keeping the website reliable and secure, to improve your experience on our website and to see how you interact with it. By accepting, you agree to our use of such cookies. Privacy Policy