gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

worktree: `commit` and `status` are worktree aware

Open schacon opened this issue 1 month ago • 1 comments

Worktrees are different than virtual branches - you can't have virtual branches in a worktree (we don't want cascading virtual branches), but we want to still use the but commands, which means that status and commit should be aware that they're in a worktree and do simpler versions of what they do.

Status should look like this:

❯ but st
You are in the `sc-feature-bee` worktree, based off the `sc-feature` branch
Main workspace is at: /Users/schacon/projects/why
To test or integrate this work, run the but worktree swap/integrate commands in the main space

╭┄00 [Unassigned Changes]
┊   ve M README.md
┊   gc M test/test_helper.rb
┊
┊╭┄t6 [sc-feature-bee]
┊●   f381269 worktree change v1
├╯
┊
● 204e309 (common base) [origin/main] Merge pull request #10 from schacon/sc-description

There should never be more than one branch, nor a stacked branch. This is simple mode, one tree.

Commit should look like:

❯ but commit -m 'testing'
Created commit 3c7a4a6 on worktree sc-feature-bee
  - targeting branch sc-feature in /Users/schacon/projects/why workspace

schacon avatar Nov 07 '25 10:11 schacon

Just some notes: as far as the workspace is concerned right now, worktrees aren't special and they are just attached to a branch that their HEAD happens to check out. As such, these branches can be in a gitbutler workspace.

With that said, this also means that initially they will be like single-branch mode, which still needs some target specification to know which commits to not include. Thus, with single-branch getting better, worktrees will get better.

Byron avatar Nov 07 '25 13:11 Byron