gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

worktree: better wt listing

Open schacon opened this issue 1 month ago • 0 comments

The but worktree list command should be run when you type but worktree. If there are no worktrees, then inform the user how to create one.

If there are worktrees, make the output more friendly.

Current output:

❯ but worktree list
Path: /Users/schacon/projects/why/.git/gitbutler/worktrees/9b7cea84-4f6a-466a-9ebb-ef60a696e0a7
Reference: refs/heads/user-changes
Base: 204e309a8298ec047e7d79497a9efcec808ddc95

Path: /Users/schacon/projects/why/.git/gitbutler/worktrees/f085b72f-08cc-4369-93b4-a22c5547ae96
Reference: refs/heads/user-changes
Base: 204e309a8298ec047e7d79497a9efcec808ddc95

Perhaps something like this:

❯ but worktree list

[user-changes-1]

  modified files:
     x5 M Gemfile
     gd A app/controllers/bookmarks_controller.rb
     n4 A app/models/bookmark.rb
     qa M app/models/user.rb
     hl A app/views/bookmarks/index.html.erb
     px M config/routes.rb

  commits:
    ●   427019e second commit
    ●   427019e first commit

  path: /Users/schacon/projects/why/.git/gitbutler/worktrees/user-changes-1
  branched from: user-changes
  base commit: 204e309 [origin/main] Merge pull request #10 from schacon/sc-description

[user-changes-2]

  modified files:
     x5 M Gemfile
     hl A app/views/bookmarks/index.html.erb

  commits:
    ●   427019e approach this a different way

  path: /Users/schacon/projects/why/.git/gitbutler/worktrees/user-changes-2
  branched from: user-changes
  base commit: 204e309 [origin/main] Merge pull request #10 from schacon/sc-description

Or, with -s or --short:

❯ but worktree list -s
user-changes-1: [e83afde] 6 modified files, 2 commits, .git/gitbutler/worktrees/user-changes-1
user-changes-2: [427019e] 2 modified files, 1 commit, .git/gitbutler/worktrees/user-changes-2

If the worktree is within the .git directory, just show the relative path on short list.

Also should work with --json.

schacon avatar Nov 07 '25 09:11 schacon