GitHub - stemps/treehouse · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
stemps
treehouse
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>10 Commits<br>10 Commits
.github/workflows
.github/workflows
scripts
scripts
.gitignore
.gitignore
.goreleaser.yaml
.goreleaser.yaml
MIT-LICENSE
MIT-LICENSE
Makefile
Makefile
README.md
README.md
VERSION
VERSION
go.mod
go.mod
main.go
main.go
main_test.go
main_test.go
View all files
Repository files navigation
Treehouse
treehouse helps you isolate your development environments when using Git<br>worktrees.
It assigns a stable number for each worktree, so you can use this number to<br>derive per-worktree local configuration like ports, database names, etc... or<br>anything you want isolated per worktree.
For example, the command
PORT="$(treehouse offset 3000)" npm run dev
will start your dev server on port 3000 on the first worktree, port 3001 on the<br>second, etc...
The worktree number is stored in .treehouse inside the worktree's local Git<br>metadata directory, as reported by git rev-parse --git-dir. For linked<br>worktrees this is usually under the repository's common .git/worktrees/<br>directory, so it is not checked in and is removed with the worktree metadata.
Installation
With Homebrew:
brew install stemps/tap/treehouse
With Go:
go install github.com/stemps/treehouse@latest
Usage
$ treehouse init<br>0 # sets the initial worktree number<br>$ treehouse current<br>0 # outputs the current worktree's number<br>$ treehouse offset 8080<br>8080 # increments the given number by the worktree's number<br>$ ./treehouse run sh -c 'echo "This is worktree $WORKTREE_NUMBER"'<br>This is worktree 0 # runs a command with WORKTREE_NUMBER set
In another worktree:
$ treehouse init<br>$ treehouse current<br>$ treehouse offset 8080<br>8081<br>$ ./treehouse run sh -c 'echo "This is worktree $WORKTREE_NUMBER"'<br>This is worktree 1
Typical Setups
Rails/Puma port:
bin/rails server -p "$(treehouse offset 3000)"
Rails database name suffix in config/database.yml:
">development:<br>adapter: postgresql<br>database: my_app_development_
Node app port:
PORT="$(treehouse offset 3000)" npm run dev
Docker published port:
docker run --rm -p "$(treehouse offset 8080):80" nginx
Node app with worktree-aware configuration:
treehouse run npm run dev
All Commands
treehouse init: assign the lowest unused non-negative worktree number.
treehouse init --set 7: explicitly store worktree number 7.
treehouse init --force: replace an existing stored number.
treehouse current: print the current worktree number.
treehouse offset : print + current worktree number.
treehouse run : run with WORKTREE_NUMBER set to<br>the current worktree number.
current, offset, and run fail if the worktree has not been initialized.<br>Use treehouse init first.
Development
go test ./...<br>go build -o treehouse .
Release
Releases are created from main with:
brew install semver<br>make release
The release task asks for a version number, writes it to VERSION, commits that<br>change, creates an annotated tag like v0.1.0, and pushes the commit and tag.<br>The tag triggers GitHub Actions to publish release artifacts and update<br>stemps/homebrew-tap.
VERSION starts at 0.0.0; enter 0.1.0 when cutting the first public<br>release. After that, make release defaults to the next patch version. Release<br>versions may use full SemVer syntax, such as 0.2.0-alpha.1, but should be<br>entered without the leading v.
Go install users can request prereleases explicitly, for example<br>go install github.com/stemps/treehouse@v0.2.0-alpha.1. @latest generally<br>prefers stable releases over prereleases.
The stemps/treehouse repository needs a HOMEBREW_TAP_GITHUB_TOKEN secret<br>with contents write access to stemps/homebrew-tap.
About
No description, website, or topics provided.
Resources
Readme
License
MIT license
Uh oh!
There was an error while loading. Please reload this page.
Activity
Stars
star
Watchers
watching
Forks
forks
Report...