git commit command is used in Git to save changes to a local repository. It creates a new commit object with a unique identifier based on the changes made, along with a message that describes the changes. This allows you to keep track of changes made to your code over time and makes it easy to revert to previous versions if necessary.
Here’s an example of how to use
- After making changes to your files, add them to the staging area with
- Once you’ve added all the changes you want to commit, run the
git commitcommand followed by a
-mflag and a message inside quotes describing the changes made. For example:
git commit -m "Added new feature to login page"
- The commit is now saved to your local repository with a unique identifier, allowing you to easily track and revert to previous versions of your code.
It’s important to note that committing changes locally only saves them to your local Git repository. To share the changes with others or push them to a remote repository, you’ll need to run
git push after committing.
Here are some links that you may find helpful: