Tracking and Committing Changes: git add and git commit
Let us record file modifications into Git history.
1. Staging Files with git add
Before you can commit changes, you must move them from the Working Directory into the Staging Area:
# Track a single file
git add index.html
# Track multiple specific files
git add styles.css main.js
# Stage all new, modified, and deleted files in the directory
git add .2. Creating History Records with git commit
Once files are staged, write them permanently to history using git commit. Always supply a clear message explaining the changes:
# Write changes with a message description
git commit -m "feat: add user login portal layout"Every commit creates a unique 40-character SHA-1 hash (for example, ce653f2...). This hash acts as an address, allowing you to reference or restore this specific version of your project in the future.
Published on Last updated: