🏠 Homepage 🏠 Syllabus of Day 2 ⬅️ Previous: 🌿 Branching in Git
After cloning a repository and switching to your branch, you can edit files using your preferred code editor (e.g., VS Code).
Before you can commit changes, you need to stage them. Staging lets you choose which changes to include in your next commit.
git add filename.txt
git add .
A commit saves your staged changes to the local repository. Always write a clear, descriptive commit message.
git commit -m "Describe your changes here"
Edit a file:
Make your changes in the code editor.
git add .
git commit -m "Add feature X or fix bug Y"
You can check which files have changed and which are staged using:
git status
Action | Command Example |
---|---|
Stage file | git add filename.txt |
Stage all files | git add . |
Commit changes | git commit -m "Your message" |
Check status | git status |
Tip:
Commit often with meaningful messages to keep your project history clear and easy to
➡️Up Next: ✅ Pushing Changes