Skip to content

Commit a2565d5

Browse files
committed
Update README with accurate implementation details
1 parent e6a329d commit a2565d5

File tree

1 file changed

+147
-29
lines changed

1 file changed

+147
-29
lines changed

README.md

Lines changed: 147 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,175 @@
22

33
**Snapshots of your Git-ignored files. Because resets shouldn't mean regrets.**
44

5-
`ignoregrets` is a lightweight, local-only CLI tool for snapshotting and restoring Git-ignored files (e.g., build artifacts, .env files, IDE metadata) tied to Git commits. It helps preserve ephemeral or environment-specific files that would otherwise be lost during branch switches or resets.
5+
`ignoregrets` is a lightweight, local-only CLI tool designed for solo developers to snapshot and restore Git-ignored files (e.g., build artifacts, `.env` files, IDE metadata) tied to Git commits. It prevents the loss of ephemeral or environment-specific files during branch switches or resets. Snapshots are stored as `.tar.gz` archives in `.ignoregrets/snapshots/` with a `manifest.json` for metadata and SHA256 checksums, ensuring integrity and safety.
66

77
## Features
88

9-
- Create snapshots of Git-ignored files, linked to commit hashes
10-
- Store snapshots locally as `.tar.gz` archives with SHA256 checksums
11-
- Restore files safely with dry-run and force options
12-
- Track file changes with detailed status reporting
13-
- Manage snapshots with retention policies
14-
- Optional Git hooks for automatic snapshots and restores
15-
- Config-first approach with CLI flag overrides
9+
- Snapshot Git-ignored files (from `.gitignore` and `.git/info/exclude`) tied to commit hashes.
10+
- Store snapshots locally as `.tar.gz` archives in `.ignoregrets/snapshots/`.
11+
- Restore files safely with `--dry-run` previews and `--force` overwrite protection.
12+
- Compare current files to snapshots with detailed status reporting.
13+
- Manage snapshot retention with pruning to prevent storage bloat.
14+
- Automate snapshots and restores with optional `pre-commit` and `post-checkout` Git hooks.
15+
- Configure via `.ignoregrets/config.yaml` with CLI flag overrides.
16+
- Cross-platform support (Linux, macOS, Windows) with minimal dependencies.
1617

1718
## Installation
1819

1920
```bash
2021
go install github.com/Cod-e-Codes/ignoregrets@latest
2122
```
23+
Requires Go 1.24.4 or later.
2224

2325
## Quick Start
2426

25-
1. Initialize in your Git repository:
27+
1. Initialize in a Git repository:
2628
```bash
2729
ignoregrets init --hooks
2830
```
31+
Creates `.ignoregrets/config.yaml` and installs Git hooks (if specified).
2932

30-
2. Create a snapshot:
33+
2. Snapshot ignored files:
3134
```bash
3235
ignoregrets snapshot
3336
```
3437

35-
3. Check status after changes:
38+
3. Check file drift:
3639
```bash
3740
ignoregrets status
3841
```
3942

40-
4. Restore files (with preview):
43+
4. Restore files:
4144
```bash
42-
ignoregrets restore --dry-run
43-
ignoregrets restore --force # Actually restore files
45+
ignoregrets restore --dry-run # Preview
46+
ignoregrets restore --force # Restore
4447
```
4548

4649
## Commands
4750

48-
- `snapshot`: Create a snapshot of Git-ignored files
49-
- `restore`: Restore files from a snapshot
50-
- `status`: Compare current files with latest snapshot
51-
- `prune`: Clean up old snapshots
52-
- `list`: List all available snapshots
53-
- `inspect`: Show details of a specific snapshot
54-
- `init`: Initialize repository and set up hooks
51+
### `init [--hooks]`
52+
Initialize the repository by creating `.ignoregrets/config.yaml`. Optionally installs `pre-commit` and `post-checkout` Git hooks.
53+
- **Flags**: `--hooks` (install Git hooks)
54+
- **Example**:
55+
```bash
56+
ignoregrets init --hooks
57+
```
58+
Output:
59+
```
60+
Initialized ignoregrets successfully
61+
Config file: .ignoregrets/config.yaml
62+
Git hooks installed successfully
63+
```
64+
65+
### `snapshot`
66+
Create a snapshot of Git-ignored files for the current commit, stored as `<commit>_<timestamp>_<index>.tar.gz`. Files are filtered based on `config.yaml` exclude/include patterns.
67+
- **Example**:
68+
```bash
69+
ignoregrets snapshot
70+
```
71+
72+
### `restore [--commit <sha>] [--snapshot <index>] [--force] [--dry-run]`
73+
Restore files from the latest snapshot for the current commit (or specified commit/index).
74+
- **Flags**:
75+
- `--commit`: Restore from specific commit hash
76+
- `--snapshot`: Specific snapshot index (default: latest)
77+
- `--force`: Overwrite existing files
78+
- `--dry-run`: Preview restore actions
79+
- **Example**:
80+
```bash
81+
ignoregrets restore --commit abc123 --dry-run
82+
```
83+
Output:
84+
```
85+
Would restore:
86+
- build/output
87+
- .env
88+
No files will be restored (dry-run mode).
89+
```
90+
91+
### `status [--verbose]`
92+
Compare current Git-ignored files to the latest snapshot for the current commit.
93+
- **Flags**:
94+
- `--verbose`: Show detailed per-file differences including checksums
95+
- **Example**:
96+
```bash
97+
ignoregrets status --verbose
98+
```
99+
Output:
100+
```
101+
Snapshot for commit abc123:
102+
- Unchanged: build/output
103+
- Modified: .env
104+
Old checksum: abc123...
105+
New checksum: def456...
106+
- Added: newfile.txt
107+
- Deleted: oldfile.log
108+
```
109+
110+
### `prune [--retention <N>]`
111+
Delete older snapshots, keeping the latest N per commit (default: config `retention`).
112+
- **Flags**:
113+
- `--retention`: Number of snapshots to keep per commit
114+
- **Example**:
115+
```bash
116+
ignoregrets prune --retention 5
117+
```
118+
Output:
119+
```
120+
Pruning snapshots for commit abc123:
121+
Deleting abc123_20250726T0233_1.tar.gz
122+
```
123+
124+
### `list`
125+
List all snapshots with commit hash, timestamp, index, and file count.
126+
- **Example**:
127+
```bash
128+
ignoregrets list
129+
```
130+
Output:
131+
```
132+
Available snapshots:
133+
--------------------
134+
Commit: abc123
135+
[0] 2025-07-26 02:33:00 (2 files)
136+
```
137+
138+
### `inspect [--commit <sha>] [--snapshot <index>] [--verbose]`
139+
Show details of a snapshot (default: latest for current commit).
140+
- **Flags**:
141+
- `--commit`: Commit hash of snapshot
142+
- `--snapshot`: Snapshot index
143+
- `--verbose`: Show file checksums
144+
- **Example**:
145+
```bash
146+
ignoregrets inspect --commit abc123 --verbose
147+
```
148+
Output:
149+
```
150+
Snapshot details:
151+
----------------
152+
Commit: abc123
153+
Timestamp: 2025-07-26 02:33:00
154+
Index: 0
155+
156+
Configuration:
157+
Retention: 10
158+
Snapshot on: [commit]
159+
Restore on: [checkout]
160+
Hooks enabled: false
161+
Exclude: [*.log]
162+
Include: [.env]
163+
164+
Files (2 total):
165+
build/output
166+
SHA256: abc123...
167+
.env
168+
SHA256: def456...
169+
```
55170

56171
## Configuration
57172

58173
Configuration is stored in `.ignoregrets/config.yaml`:
59-
60174
```yaml
61175
retention: 10 # Snapshots to keep per commit
62176
snapshot_on: [commit] # Git events for auto-snapshot
@@ -66,16 +180,15 @@ exclude: ["*.log"] # Glob patterns to exclude
66180
include: [".env"] # Additional files to include
67181
```
68182
69-
CLI flags override config values:
183+
Override retention with CLI flags:
70184
```bash
71-
ignoregrets snapshot --retention 5
185+
ignoregrets prune --retention 5
72186
ignoregrets restore --force --commit abc123 --snapshot 0
73-
ignoregrets status --verbose
74187
```
75188

76189
## Git Hooks
77190

78-
When enabled, `ignoregrets` installs:
191+
When enabled (`hooks_enabled: true` or `ignoregrets init --hooks`):
79192
- `pre-commit`: Creates snapshots before committing
80193
- `post-checkout`: Suggests restores after branch switches
81194

@@ -119,13 +232,18 @@ Enable hooks via:
119232
- **"no files to snapshot"**: No ignored files found
120233
- **"manifest.json not found"**: Snapshot corrupted
121234

235+
For Windows users: Git hooks are installed with appropriate permissions, but you may need to run with administrator privileges for certain operations.
236+
122237
## Contributing
123238

124239
1. Fork the repository
125240
2. Create a feature branch
126-
3. Make your changes
127-
4. Submit a pull request
241+
3. Write idiomatic Go code with tests in the appropriate `internal/*/test.go` files
242+
4. Run tests: `go test ./...`
243+
5. Submit a pull request
244+
245+
Code style: Follow Go conventions, use single-responsibility functions, and include comments for clarity.
128246

129247
## License
130248

131-
MIT License - see LICENSE file for details
249+
MIT License - see [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)