Skip to content

Commit af9e897

Browse files
authored
Merge pull request #20 from BHFock/br
feat: Add automated branch creation workflow (git cl branch)
2 parents 442e5fd + 8ecd702 commit af9e897

File tree

4 files changed

+419
-157
lines changed

4 files changed

+419
-157
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ git-cl is a minimal Git subcommand that brings changelist support to Git. Organi
77
88
[![Git Changelist Tutorial](https://img.shields.io/badge/Tutorial-View-blue)](https://github.com/BHFock/git-cl/blob/main/docs/tutorial.md)
99

10-
11-
`git-cl` is a command-line tool that offers Git changelist support, inspired by Subversion. It allows users to assign working directory files to named changelists, helping organise work by intent and manage partial commits more easily.
10+
`git-cl` is a command-line tool that offers Git changelist support, inspired by Subversion. It allows users to assign working directory files to named changelists, helping organise work by intent, manage partial commits, and create branches directly from a changelist.
1211

1312
Perfect for developers who prefer to organise their work logically from the start, rather than managing complex commit history afterward.
1413

@@ -18,6 +17,7 @@ Perfect for developers who prefer to organise their work logically from the star
1817
- Work on multiple features on a single branch
1918
- Stage and commit changes by intent
2019
- Stash changelists and resume work later
20+
- Create a new branch directly from a changelist
2121
- Local-only metadata (`.git/cl.json`)
2222
- Simple CLI: `git cl <command>`
2323

@@ -68,6 +68,9 @@ git cl delete docs-fix
6868
git cl stash docs-fix
6969
git checkout -b docs-fix-work
7070
git cl unstash docs-fix
71+
72+
# Create and switch to a new branch from a changelist (auto-stash/unstash)
73+
git cl br docs-fix
7174
```
7275

7376
## Example Output
@@ -88,15 +91,10 @@ git cl unstash docs-fix
8891

8992
## Project status
9093

91-
`git-cl` is developed as a personal side project. Future updates may happen as time and interest allow, but no ongoing development or community involvement is planned.
94+
`git-cl` is now feature complete. All planned functionality has been implemented, including changelist creation, staging, committing, stashing, and branching. Future updates will focus on code refactoring, bug fixes, and usability improvements — no major new features are planned.
9295

9396
Use, fork, or adapt freely under the BSD license.
9497

95-
96-
## Future Ideas
97-
98-
Some ideas for features are outlined in [`docs/FUTURE.md`](docs/FUTURE.md).
99-
10098
## License
10199

102100
BSD 3-Clause License — see [LICENSE](./LICENSE) for details.

docs/FUTURE.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

docs/tutorial.md

Lines changed: 87 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ git-cl: A Git subcommand to manage changelists in Git. Group files by intent, ma
2121
- [2.5 Commit a changelist](#25-commit-a-changelist)
2222
- [2.6 Remove files from changelists](#26-remove-files-from-changelists)
2323
- [2.7 Delete changelists](#27-delete-changelists)
24-
- [2.8 Stash and Unstash Changelists](#28-stash-and-unstash-changelists)
25-
- [2.9 Checkout a Changelist](#29-checkout-a-changelist)
26-
- [3. Example Workflows](#3-example-workflows)
27-
- [3.1 Changelists as Named Staging Areas](#31-changelists-as-named-staging-areas)
28-
- [3.2 Branching Mid-Feature with git cl stash](#32-branching-mid-feature-with-git-cl-stash)
29-
- [4. FAQ & Common Pitfalls](#4-faq--common-pitfalls)
30-
- [5. Command Summary](#5-command-summary)
31-
- [5.1 Command Summary Table](#51-command-summary-table)
32-
- [5.2 Git Status Code Reference](#52-git-status-code-reference)
24+
- [2.8 Checkout a changelist](#28-checkout-a-changelist)
25+
- [3. Advanced Commands](#3-advanced-commands)
26+
- [3.1 Stash and Unstash changelists](#31-stash-and-unstash-changelists)
27+
- [3.2 Create a branch from a changelist](#32-create-a-branch-from-a-changelist)
28+
- [4. Example Workflows](#4-example-workflows)
29+
- [4.1 Changelists as named staging areas](#41-changelists-as-named-staging-areas)
30+
- [4.2 Branching mid-feature with git cl stash](#42-branching-mid-feature-with-git-cl-stash)
31+
- [5. FAQ & Common Pitfalls](#5-faq--common-pitfalls)
32+
- [6. Command Summary](#6-command-summary)
33+
- [6.1 Command Summary Table](#61-command-summary-table)
34+
- [6.2 Git Status Code Reference](#62-git-status-code-reference)
3335

3436
</details>
3537

@@ -334,7 +336,26 @@ git cl delete --all
334336

335337
Only changelist metadata is deleted — no file content or Git history is lost.
336338

337-
### 2.8 Stash and Unstash Changelists
339+
### 2.8 Checkout a Changelist
340+
341+
```
342+
git cl checkout <changelist-name>
343+
# or
344+
git cl co <changelist-name>
345+
```
346+
347+
- Reverts all files in the changelist to their last committed state ([HEAD](https://git-scm.com/book/ms/v2/Git-Tools-Reset-Demystified.html#_the_head)).
348+
- Useful for discarding local changes by intent, not just by filename.
349+
- Prompts for confirmation before proceeding.
350+
- Shows a summary of reverted files.
351+
352+
353+
[↑ Back to top](#git-cl-a-git-subcommand-for-changelist-management)
354+
355+
356+
## 3. Advanced Commands
357+
358+
### 3.1 Stash and Unstash Changelists
338359

339360
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.
340361

@@ -365,24 +386,46 @@ git cl stash --all
365386

366387
- Stashes all active changelists at once
367388

368-
### 2.9 Checkout a Changelist
389+
390+
### 3.2 Create a branch from a changelist
369391

370392
```
371-
git cl checkout <changelist-name>
372-
# or
373-
git cl co <changelist-name>
393+
git cl branch <changelist-name> [<branch-name>] [--from <base-branch>]
374394
```
375395

376-
- Reverts all files in the changelist to their last committed state ([HEAD](https://git-scm.com/book/ms/v2/Git-Tools-Reset-Demystified.html#_the_head)).
377-
- Useful for discarding local changes by intent, not just by filename.
378-
- Prompts for confirmation before proceeding.
379-
- Shows a summary of reverted files.
396+
Creates a new branch for a changelist and restores its files there in one step.
397+
398+
1. Stashes all active changelists to clean the working directory.
399+
2. Creates and checks out the new branch (defaults to <changelist> from the current branch, or use --from).
400+
3. Unstashes only the chosen changelist onto the new branch; others stay stashed.
401+
402+
Preconditions:
403+
404+
- Changelist exists and not already stashed.
405+
- Must be on a branch (not detached HEAD).
406+
- No unassigned modified files (except untracked).
407+
408+
### Example
409+
410+
```
411+
# Create a changelist for feature x
412+
git cl add feature-x src/app.py src/utils.py
413+
414+
# Create changelist with other changes to stash away
415+
git cl add docs docs/tutorial.md README
416+
417+
# Create a branch named after the changelist
418+
git cl br feature-x
419+
```
420+
421+
422+
380423

381424
[↑ Back to top](#git-cl-a-git-subcommand-for-changelist-management)
382425

383-
## 3. Example Workflows
426+
## 4. Example Workflows
384427

385-
### 3.1 Changelists as Named Staging Areas
428+
### 4.1 Changelists as Named Staging Areas
386429

387430
`git-cl` changelists function as named pre-staging areas. Instead of staging files directly, you organise them into changelists — then selectively stage or commit based on those names.
388431

@@ -410,7 +453,7 @@ git commit -m "Implement core feature"
410453
The other changelists remain untouched, keeping your workspace organised and uncommitted changes visible.
411454

412455

413-
### 3.2 Branching Mid-Feature with git cl stash
456+
### 4.2 Branching Mid-Feature with git cl stash
414457

415458
Sometimes you're midway through a changelist but need to pause and start a new branch — without committing unfinished work. `git cl stash` makes that safe and simple.
416459

@@ -432,7 +475,7 @@ This preserves your work-in-progress and the changelist grouping — so you can
432475

433476
[↑ Back to top](#git-cl-a-git-subcommand-for-changelist-management)
434477

435-
## 4. FAQ & Common Pitfalls
478+
## 5. FAQ & Common Pitfalls
436479

437480
### How do I move a file from one changelist to another?
438481

@@ -507,28 +550,28 @@ Yes. If the changelist was deleted after a stage or commit, you can create a new
507550

508551
[↑ Back to top](#git-cl-a-git-subcommand-for-changelist-management)
509552

510-
## 5. Command Summary
511-
512-
### 5.1 Command Summary Table
513-
514-
| Task | Command | Alias |
515-
| ------------------------------ | ---------------------------------------------- | ------------ |
516-
| Add files to a changelist | `git cl add <name> <files...>` | `git cl a` |
517-
| View grouped status | `git cl status` / `git cl st` | `git cl st` |
518-
| View all statuses, no color | `git cl status --all --no-color` | |
519-
| Show diff for changelist(s) | `git cl diff <name1> [<name2> ...] [--staged]` | |
520-
| Stage a changelist | `git cl stage <name> [--delete]` | |
521-
| Unstage a changelist | `git cl unstage <name> [--delete]` | |
522-
| Commit with inline message | `git cl commit <name> -m "Message" [--keep]` | `git cl ci` |
523-
| Commit using message from file | `git cl commit <name> -F message.txt [--keep]` | |
524-
| Revert changelist to HEAD | `git cl checkout <name>` | `git cl co` |
525-
| Remove files from changelists | `git cl remove <file1> <file2> ...` | `git cl rm` |
526-
| Delete changelists | `git cl delete <name1> <name2> ...` | `git cl del` |
527-
| Delete all changelists | `git cl delete --all` | |
528-
| Show help | `git cl help` | |
529-
530-
531-
### 5.2 Git Status Code Reference
553+
## 6. Command Summary
554+
555+
### 6.1 Command Summary Table
556+
557+
| Task | Command | Alias |
558+
| ------------------------------- | --------------------------------------------------------- | ------------- |
559+
| Add files to a changelist | `git cl add <name> <files...>` | `git cl a` |
560+
| View grouped status | `git cl status [--all] [--no-color] ` | `git cl st` |
561+
| Show diff for changelist(s) | `git cl diff <name1> [<name2> ...] [--staged]` | |
562+
| Stage a changelist | `git cl stage <name> [--delete]` | |
563+
| Unstage a changelist | `git cl unstage <name> [--delete]` | |
564+
| Commit with inline message | `git cl commit <name> -m "Message" [--keep]` | `git cl ci` |
565+
| Commit using message from file | `git cl commit <name> -F message.txt [--keep]` | |
566+
| Revert changelist to HEAD | `git cl checkout <name>` | `git cl co` |
567+
| Remove files from changelists | `git cl remove <file1> <file2> ...` | `git cl rm` |
568+
| Delete changelists | `git cl delete <name1> <name2> ...` | `git cl del` |
569+
| Stash a changelist | `git cl stash <name>` | |
570+
| Unstash a changelist | `git cl unstash <name> [--force]` | |
571+
| Create branch from changelist | `git cl branch <name> [<branch>] [--from <base>]` | `git cl br` |
572+
| Show help | `git cl help` | |
573+
574+
### 6.2 Git Status Code Reference
532575

533576
`git cl status` uses standard Git status codes — shown as two-character prefixes (e.g. `[M ]`, `[??]`).
534577

0 commit comments

Comments
 (0)