Git Commit Basics
Understanding Git Version Control
Git commit is a fundamental operation in git version control that captures a snapshot of your project's current state. When developers make changes to their codebase, commits create a permanent record of those modifications.
Core Commit Components
A Git commit consists of several key elements:
Component |
Description |
Author |
Person making the commit |
Timestamp |
Exact time of commit |
Commit Message |
Descriptive text explaining changes |
Unique Hash |
SHA-1 identifier for the commit |
Basic Commit Workflow
graph LR
A[Working Directory] --> B[Staging Area]
B --> C[Repository]
Command Line Commit Examples
## Configure git user
git config --global user.name "John Doe"
git config --global user.email "[email protected]"
## Stage specific files
git add README.md src/main.py
## Commit with message
git commit -m "Add user authentication module"
## Stage and commit all modified files
git commit -am "Update login functionality"
Commit Fundamentals in Practice
Commits track code changes, providing a chronological history of project development. Each commit represents a discrete set of modifications, enabling developers to understand project evolution and revert changes if needed.