Welcome to Hacktoberfest 2025Tutorials
Commit Changes
Learn how to commit your changes with good commit messages
Commit Changes
Committing saves your changes to your local Git history with a descriptive message.
What is a Commit?
A commit is like a snapshot of your project at a specific point in time. It includes:
- The changes you made
- A message describing the changes
- Author information
- Timestamp
Step-by-Step Guide
Step 1: Check Your Changes
# See what files you changed
git status
# See the actual changes
git diffStep 2: Stage Your Changes
# Stage specific files
git add filename.txt
# Stage all changes
git add .
# Stage multiple specific files
git add file1.txt file2.txt file3.txtStep 3: Commit Your Changes
# Commit with a message
git commit -m "Fix typo in README.md"
# For longer messages, use an editor
git commitWriting Good Commit Messages
The Format
Type: Brief description (50 chars or less)
More detailed explanation if needed (wrap at 72 chars).
Explain what and why, not how.
- Bullet points are okay
- Use present tense: "Add feature" not "Added feature"
- Reference issues: "Fixes #123"Commit Types
Fix:- Bug fixesAdd:- New featuresUpdate:- Updates to existing featuresRemove:- Removing code or filesRefactor:- Code refactoringDocs:- Documentation changesStyle:- Formatting, missing semicolons, etc.Test:- Adding testsChore:- Maintenance tasks
Good Examples ✅
git commit -m "Fix: Correct broken link in footer"
git commit -m "Add: Dark mode toggle button"
git commit -m "Update: Improve error handling in API"
git commit -m "Docs: Add installation instructions"Bad Examples ❌
git commit -m "fix"
git commit -m "updates"
git commit -m "changed stuff"
git commit -m "asdfasdf"Verify Your Commit
# See your commit history
git log
# See the last commit
git log -1
# See commits with changes
git log -p
# See a prettier log
git log --oneline --graphAmending Commits
Made a mistake? You can fix your last commit:
# Change the commit message
git commit --amend -m "New message"
# Add forgotten files
git add forgotten-file.txt
git commit --amend --no-editOnly amend commits that haven't been pushed yet!
Next Steps
Your changes are now committed! Time to push them to GitHub. 💾