⚠️ WARNING: This project is no longer maintained. The core functionality of automatically changing directories when switching worktrees is not possible due to fundamental limitations in how shells interact with child processes. A child process cannot modify its parent shell's working directory. While shell integration scripts can work around this, they add significant complexity and are not reliable across all environments. For a simpler solution, consider using git worktrees directly or building your own aliases/commands to provide the experience you want.
Manage git repositories using Git worktrees.
Git worktrees are awesome, but to use them effectively, some prior organization helps. git-manager
is a command-line tool that helps you organize and manage multiple git repositories using git worktrees. It puts them in a special directory to ensure that it does not conflict with current git repositories that might be managed in different ways.
- Create and manage git repositories
- Create and manage git worktrees for a given repository
- Navigate between different worktrees and repositories
- Organize repositories efficiently
- Streamline git workflow
- Automatic directory switching with shell integration
go install github.com/ingshtrom/git-manager@latest
Since a command-line tool cannot directly change the parent shell's directory, git-manager
provides shell integration to make directory switching seamless.
The shell integration works by:
- Wrapping the
git-manager
command with a shell function - Capturing the output of the command
- Looking for special
git-manager-eval:
prefixed lines - Evaluating any commands with this prefix in the shell
- Displaying all other output normally
This allows commands like switch
to change your current directory automatically when shell integration is enabled.
Once shell integration is set up, you can use git-manager
(or the shorter alias gm
) as usual:
# Switch to a worktree and automatically change directory
git-manager switch feature-branch
# Or use the shorter alias
gm switch feature-branch
- get the dev task running, this gets the binary built in near-real-time. It ouputs to the
./build
directory:
$ task dev
- install the shell integration
- Modify your shell integration script to point to
<cwd>/build/git-manager
instead of the globally installed git-manager - restart your shell so that the newest shell integration is active
- test with
gm
command
You can run tests locally:
# Run all tests
task test
# Run tests with coverage
task test:cover
For consistent testing across environments, you can run tests in Docker:
# Run all tests in Docker
task test:docker
# Run specific tests in Docker
task test:docker:specific -- ./internal/worktree
# Run tests with coverage in Docker
task test:docker:cover
For more information about Docker-based testing, see Docker Testing Documentation.
See the LICENSE file for details.