~/
hackweb.dev
Staging and Committing
Quiz
⌘K
...
~/
/tutorials
/git/git-add-commit/edit
~ Contribute
Suggest a correction or improvement. The author reviews it before it goes live.
Loading...
Comment
0 / 300
Typo
Grammar
Broken link
Clarify
Code
en/tutorials/git/4git-add-commit
Write
Preview
Diff
# Staging and Committing Git uses a three-step process to save changes: working directory → staging area → repository. ## The Three Areas 1. **Working directory**: Files you edit directly 2. **Staging area**: Changes marked for the next commit 3. **Repository**: Permanent history of commits ```text Working Directory → git add → Staging Area → git commit → Repository ``` ## Staging Changes Add specific files: ```bash git add file.txt ``` Add all changes: ```bash git add . ``` ## Committing Changes Save staged changes with a message: ```bash git commit -m "Add login page" ``` ## Good Commit Messages - Use the imperative mood ("Add feature" not "Added feature") - Keep under 72 characters - Explain what changed and why - Reference issue numbers when relevant ## Best Practices - Commit early and often - Don't stage and commit unrelated changes - Write meaningful commit messages - Review changes before committing with `git diff` ## Common Mistakes - Committing all changes without staging first - Using vague messages like "fix" or "update" - Committing large files or sensitive data - Forgetting to add files before committing
No changes yet
Reset to original
Submit suggestion
cancel