Skip to content

Commit 93df954

Browse files
authored
Merge pull request #14 from BHFock/stash
Add stash/unstash support for changelists (`git cl stash`, `git cl unstash`)
2 parents 19b3875 + fcddc51 commit 93df954

File tree

4 files changed

+1764
-178
lines changed

4 files changed

+1764
-178
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Perfect for developers who prefer to organise their work logically from the star
1717
- Group files logically before staging using Git changelists
1818
- Work on multiple features on a single branch
1919
- Stage and commit changes by intent
20+
- Stash changelists and resume work later
2021
- Local-only metadata (`.git/cl.json`)
2122
- Simple CLI: `git cl <command>`
2223

@@ -62,6 +63,11 @@ git cl remove README.md
6263

6364
# Delete a changelist
6465
git cl delete docs-fix
66+
67+
# Temporarily stash a changelist and resume work on a new branch
68+
git cl stash docs-fix
69+
git checkout -b docs-fix-work
70+
git cl unstash docs-fix
6571
```
6672

6773
## Example Output

docs/FUTURE.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@ Combine two or more changelists into a new one.
2222
- Merges file assignments from multiple lists
2323
- Ideal for consolidating related work
2424

25-
### `git cl stash list_name`
26-
Temporarily shelve changes in a changelist.
27-
28-
- Saves file changes and changelist metadata
29-
- Tracks stash reference internally
30-
- Displays stashed state in `git cl st`
31-
32-
### `git cl unstash list_name`
33-
Restore a previously stashed changelist to the working directory.
34-
35-
- Recovers both file changes and changelist context
36-
- Seamless integration with ongoing work
37-
3825
### `git cl br list_name [branch_name]`
3926
Create a new Git branch for a changelist.
4027

docs/tutorial.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ git-cl: A Git subcommand to manage changelists in Git. Group files by intent, ma
2525
- [2.5 Commit a changelist](#25-commit-a-changelist)
2626
- [2.6 Remove files from changelists](#26-remove-files-from-changelists)
2727
- [2.7 Delete changelists](#27-delete-changelists)
28+
- [2.8 Stash and Unstash Changelists](#28-stash-and-unstash-changelists)
2829
- [3. Example Workflow: Changelists as Named Staging Areas](#3-example-workflow-changelists-as-named-staging-areas)
2930
- [4. FAQ & Common Pitfalls](#4-faq--common-pitfalls)
3031
- [5. Command Summary](#5-command-summary)
@@ -326,6 +327,55 @@ git cl delete --all
326327

327328
Only changelist metadata is deleted — no file content or Git history is lost.
328329

330+
### 2.8 Stash and Unstash Changelists
331+
332+
You can temporarily shelve changelists using `stash`, then restore them later with `unstash`. This is useful when switching branches or pausing work on a feature.
333+
334+
#### Stash a changelist
335+
336+
```
337+
git cl stash <changelist-name>
338+
```
339+
340+
- Saves unstaged and untracked changes from the changelist.
341+
- Staged changes are skipped.
342+
- The stash is named after the changelist and timestamped.
343+
344+
#### Unstash a changelist
345+
346+
```
347+
git cl unstash <changelist-name>
348+
```
349+
350+
- Restores the previously stashed changes.
351+
- Warns if files conflict with current working directory.
352+
353+
#### Stash all changelists
354+
355+
```
356+
git cl stash --all
357+
```
358+
359+
- Stashes all active changelists.
360+
- Useful before switching branches or pulling updates.
361+
362+
#### Unstash all changelists
363+
364+
```
365+
git cl unstash --all
366+
```
367+
- Restores all previously stashed changelists.
368+
369+
#### Example
370+
371+
```
372+
git cl stash docs
373+
git checkout feature-branch
374+
git cl unstash docs
375+
```
376+
377+
This lets you move work-in-progress between branches without committing or losing context.
378+
329379
[↑ Back to top](#git-cl-a-git-subcommand-for-changelist-management)
330380

331381
## 3. Example Workflow: Changelists as Named Staging Areas

0 commit comments

Comments
 (0)