1
0
Fork 0
mirror of https://github.com/imjasonh/cnotes synced 2026-07-18 14:47:18 +00:00

Complete git notes preservation documentation and cleanup

- Added comprehensive documentation for notes preservation during rebasing/squashing
- Updated CLAUDE.md with backup/restore command examples
- Documented best practices for preserving conversation context during destructive git operations
- Cleaned up test files

All git notes preservation features are now complete and documented.
This commit is contained in:
Jason Hall 2025-07-21 12:40:04 -04:00
parent 7b6cdffa8a
commit 5d9e678db8
Failed to extract signature
4 changed files with 56 additions and 74 deletions

View file

@ -58,6 +58,7 @@ This is a Claude Code hooks system that intercepts and processes all tool usage
**`cmd/`** - CLI interface using Cobra **`cmd/`** - CLI interface using Cobra
- `run.go` - Handles hook execution (called by Claude Code) - `run.go` - Handles hook execution (called by Claude Code)
- `install.go` - Manages hook installation/uninstallation - `install.go` - Manages hook installation/uninstallation
- `notes.go` - Git notes backup, restore, and management commands
### Type Safety and JSON Handling ### Type Safety and JSON Handling
@ -138,6 +139,20 @@ git log --show-notes=claude-conversations --oneline
- Commit context (command and git output) - Commit context (command and git output)
- Claude version information - Claude version information
**Notes Preservation**:
```bash
# Backup all conversation notes
./hooks notes backup [filename]
# List all commits with notes
./hooks notes list
# Restore from backup after destructive operations
./hooks notes restore <filename>
```
The system automatically warns before destructive git operations and configures git to preserve notes during rewrites.
## Key Design Principles ## Key Design Principles
- **No Type Casting**: All JSON handling uses proper unmarshaling to typed structs - **No Type Casting**: All JSON handling uses proper unmarshaling to typed structs

View file

@ -223,6 +223,47 @@ git fetch origin refs/notes/claude-conversations:refs/notes/claude-conversations
git config remote.origin.fetch '+refs/notes/*:refs/notes/*' git config remote.origin.fetch '+refs/notes/*:refs/notes/*'
``` ```
### Preserving Notes During Rebasing and Squashing
**⚠️ Important**: Git notes can be lost during rebase, squash, and other destructive operations. This hooks system includes comprehensive protection:
#### Automatic Protection
The system automatically:
- **Warns before destructive operations** like `git rebase`, `git reset --hard`, `git commit --amend`
- **Configures git to preserve notes** during rebase operations
- **Provides backup and restore commands** for manual recovery
#### Manual Backup and Restore
```bash
# Backup all conversation notes
./hooks notes backup my-notes-backup.json
# List all commits with notes
./hooks notes list
# Restore notes from backup (after rebase/squash)
./hooks notes restore my-notes-backup.json
```
#### Automatic Git Configuration
The system configures git to preserve notes:
```bash
git config notes.rewrite.mode copy
git config notes.rewriteRef refs/notes/claude-conversations
```
This ensures notes are automatically copied to new commit hashes during rebasing.
#### Best Practices
1. **Before major rebasing**: Run `./hooks notes backup` to create a safety backup
2. **Use the copy mode**: The system auto-configures git to copy notes during rewrites
3. **Check after operations**: Run `./hooks notes list` to verify notes are preserved
4. **Manual restore**: Use `./hooks notes restore` if any notes are lost
## Testing Hooks ## Testing Hooks
Test individual hooks by piping JSON: Test individual hooks by piping JSON:

View file

@ -1,2 +0,0 @@
# Test rebase notes preservation
# Test commit 2

File diff suppressed because one or more lines are too long