feat: add git-worktree-flow-adopt and git-worktree-flow-eject commands#73
Merged
feat: add git-worktree-flow-adopt and git-worktree-flow-eject commands#73
Conversation
Add two commands for converting repositories between traditional and worktree-style layouts: - git-worktree-flow-adopt: Convert traditional repo to worktree layout - Preserves uncommitted changes - Supports --dry-run, --quiet, --verbose, --trust-hooks, --no-hooks - Comprehensive man page with workflow documentation - git-worktree-flow-eject: Convert worktree layout back to traditional - Supports -b/--branch to specify which branch to keep - Supports --force to delete dirty worktrees - Handles uncommitted changes appropriately These are explicit, infrequently-used commands without shortcuts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove bare repo index file after adopt (bare repos don't need one) - Initialize worktree index with git reset after adopt - Add cd_path output to eject command for shell wrapper - Add flow-adopt and flow-eject to shell wrappers (bash/zsh/fish) - Add tests for clean git status after adopt Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use a staging directory inside .git/ to safely move project files during adopt. This fixes the case where the branch name (e.g., "test") matches an existing directory in the project - previously this would fail with "Invalid argument" when trying to move a directory into its own subdirectory. The fix moves files in two steps: 1. Move all files to .git/daft-adopt-staging/ 2. Create the worktree directory and move files from staging Also fixes missing `remote` field in init.rs tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When running eject without --branch and the default branch (master/main) doesn't have a worktree, the command now falls back to the first available worktree instead of failing with an error. This fixes the case where a user only has a non-default branch worktree (e.g., "test") and runs eject - it now correctly uses that branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use a staging directory inside .git/ to safely move files during eject. This fixes the case where the branch name (e.g., "test") matches a directory inside the worktree - previously this would fail when trying to move test/test to test while the worktree directory still exists. The fix moves files in three steps: 1. Move files from worktree to .git/daft-eject-staging/ 2. Remove the worktree directory 3. Move files from staging to project root Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add symlinks and tests for the new git-worktree-flow-adopt and git-worktree-flow-eject commands to the CI workflow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
13 tasks
avihut
added a commit
that referenced
this pull request
Jan 24, 2026
#73) * feat: add git-worktree-flow-adopt and git-worktree-flow-eject commands Add two commands for converting repositories between traditional and worktree-style layouts: - git-worktree-flow-adopt: Convert traditional repo to worktree layout - Preserves uncommitted changes - Supports --dry-run, --quiet, --verbose, --trust-hooks, --no-hooks - Comprehensive man page with workflow documentation - git-worktree-flow-eject: Convert worktree layout back to traditional - Supports -b/--branch to specify which branch to keep - Supports --force to delete dirty worktrees - Handles uncommitted changes appropriately These are explicit, infrequently-used commands without shortcuts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: resolve adopt/eject post-conversion issues - Remove bare repo index file after adopt (bare repos don't need one) - Initialize worktree index with git reset after adopt - Add cd_path output to eject command for shell wrapper - Add flow-adopt and flow-eject to shell wrappers (bash/zsh/fish) - Add tests for clean git status after adopt Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle adopt when branch name matches existing directory Use a staging directory inside .git/ to safely move project files during adopt. This fixes the case where the branch name (e.g., "test") matches an existing directory in the project - previously this would fail with "Invalid argument" when trying to move a directory into its own subdirectory. The fix moves files in two steps: 1. Move all files to .git/daft-adopt-staging/ 2. Create the worktree directory and move files from staging Also fixes missing `remote` field in init.rs tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: eject falls back to available worktree when default branch missing When running eject without --branch and the default branch (master/main) doesn't have a worktree, the command now falls back to the first available worktree instead of failing with an error. This fixes the case where a user only has a non-default branch worktree (e.g., "test") and runs eject - it now correctly uses that branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle eject when branch name matches directory in worktree Use a staging directory inside .git/ to safely move files during eject. This fixes the case where the branch name (e.g., "test") matches a directory inside the worktree - previously this would fail when trying to move test/test to test while the worktree directory still exists. The fix moves files in three steps: 1. Move files from worktree to .git/daft-eject-staging/ 2. Remove the worktree directory 3. Move files from staging to project root Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * ci: add flow-adopt and flow-eject to CI workflow Add symlinks and tests for the new git-worktree-flow-adopt and git-worktree-flow-eject commands to the CI workflow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git-worktree-flow-adoptcommand to convert traditional repos to worktree layoutgit-worktree-flow-ejectcommand to convert worktree layout back to traditionalChanges
New Commands
Features
--dry-runmode--branchoption for eject to choose which branch to keep--forceoption for eject to remove dirty worktreesBug Fixes
Test plan
just test-integration-flow-adoptpasses (7 tests)just test-integration-flow-ejectpasses (8 tests)cargo clippy -- -D warningspasses🤖 Generated with Claude Code