Skip to content

Commit 0bb16ae

Browse files
committed
Add knowledge.md guidance: never use git checkout to exclude files from commits
1 parent 23176df commit 0bb16ae

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

knowledge.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ base-lite "fix this bug" # Works right away!
8989
- Force pushing is only acceptable on feature branches where you're the only contributor
9090
- If a push is rejected, use `git pull --rebase` to integrate remote changes first
9191

92+
### Preserving Uncommitted Changes
93+
94+
**NEVER use `git checkout HEAD --` or `git restore` on files to exclude them from a commit.** This destructively discards uncommitted work.
95+
96+
When the user says "don't commit file X" or "exclude file X from the commit":
97+
- ✅ Only `git add` the specific files they DO want committed
98+
- ✅ Leave other files in their current state (staged or unstaged)
99+
- ❌ NEVER run `git checkout HEAD -- <file>` or `git restore <file>` - this permanently deletes uncommitted changes
100+
101+
Correct approach for amending a commit with specific files:
102+
```bash
103+
# Only add the files to include
104+
git add path/to/file-to-include.ts
105+
git commit --amend --no-edit
106+
```
107+
92108
### Interactive Git Commands
93109

94110
**Always use tmux when running interactive git commands** (e.g., `git rebase --continue`, `git add -p`, `git commit --amend`).

0 commit comments

Comments
 (0)