Staging patches with Git add -p
4 hours ago
- `git add -p` allows interactive staging of file changes, enabling review and error detection during the commit process.
- It can split changes into hunks for selective staging, helping organize related modifications into separate commits.
- The feature provides various options like 'y' (stage), 'n' (skip), 's' (split), and 'q' (quit) for fine-grained control.
- It is not suitable for new files (no diff available) but is useful in most other scenarios, including partial file commits.
- Using `git add -p` improves commit organization and reduces errors by enabling code review at staging time.