Skip to content

Show worktree name next to branch in branches list#5340

Merged
stefanhaller merged 1 commit intojesseduffield:masterfrom
ruudk:worktree-name-in-branches-list
Mar 9, 2026
Merged

Show worktree name next to branch in branches list#5340
stefanhaller merged 1 commit intojesseduffield:masterfrom
ruudk:worktree-name-in-branches-list

Conversation

@ruudk
Copy link
Copy Markdown
Contributor

@ruudk ruudk commented Mar 4, 2026

PR Description

When a branch is checked out by another worktree, show the worktree name in the label, e.g. "(worktree cosmos2)" instead of just "(worktree)", so you can immediately see which worktree holds it.

Screenshot 2026-03-04 at 13 48 11@2x

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@ruudk ruudk force-pushed the worktree-name-in-branches-list branch from 2c7fe1f to 2079706 Compare March 5, 2026 10:05
@stefanhaller
Copy link
Copy Markdown
Collaborator

A few thoughts:

  • I'm a little concerned that it might make the branches list too noisy, especially when you also use gui.showDivergenceFromBaseBranch: arrowAndNumber (which I'm considering turning on by default at some point). This is only a minor concern though, and since we already show (worktree) when nerd fonts are not used, the difference is not that big.
  • I'm surprised that you only add the worktree name when nerd fonts are not used. I'd suspect that most lazygit users do use nerd fonts (or at least I'd hope so). If they are used, we currently show
    Screenshot 2026-03-08 at 15 28 14, and I think we should change that to
    Screenshot 2026-03-08 at 15 29 15.
  • Some people have a workflow where they create a worktree for each branch, and throw it away when they are done with the branch. For these people, worktree names and branch names are always the same, and it's redundant to show them both. We could either add a user config to turn showing the worktree name off in that case; or add a heuristic to not show the worktree name if it is the same as the branch name. I'd prefer the latter, I think.

@stefanhaller stefanhaller force-pushed the worktree-name-in-branches-list branch from 2079706 to c4bea3f Compare March 8, 2026 14:49
@stefanhaller
Copy link
Copy Markdown
Collaborator

I pushed a fixup (c4bea3f) to implement the suggestion I made above, including the heuristic to omit the worktree name if it is the same as the branch name.

I'd be mostly happy with this, but there's one problem left: if the window is so narrow that the whole branch name plus worktree name doesn't fit, then we truncate only the branch name, but leave the worktree name at full length. This doesn't make much sense; the logic did make some sense when the worktree icon was only one character, but now we should truncate the worktree name first (and maybe omit it entirely if it doesn't fit), and only then truncate the branch name too. This make the whole thing a bit more complicated.

@stefanhaller stefanhaller added the enhancement New feature or request label Mar 8, 2026
@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Mar 8, 2026

Thanks.

Can't we auto hide this worktree name when there isn't enough space?

@stefanhaller stefanhaller force-pushed the worktree-name-in-branches-list branch from c4bea3f to 9e4f8fd Compare March 8, 2026 18:51
@stefanhaller
Copy link
Copy Markdown
Collaborator

Can't we auto hide this worktree name when there isn't enough space?

Yes, that's basically what I meant, it's just not totally trivial (requires moving code around a bit). I tried this in 9e4f8fd; please have a look and test it thoroughly. I'd like to cut a release tomorrow, would be nice if we could include this PR together with the other worktree change.

@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Mar 8, 2026

I'll have a look tomorrow afternoon. Thanks!

@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Mar 9, 2026

I tested it and it works great! Also switched to nerd fonts, which makes it 😍

When a branch is checked out by another worktree, show the worktree
name in the label, e.g. "(worktree cosmos2)" instead of just
"(worktree)", so you can immediately see which worktree holds it.
@ruudk ruudk force-pushed the worktree-name-in-branches-list branch from 9e4f8fd to 6ad56d5 Compare March 9, 2026 10:34
@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Mar 9, 2026

I fixed up your commits into mine, and rebased with main.

@stefanhaller stefanhaller merged commit b05e33d into jesseduffield:master Mar 9, 2026
13 checks passed
@ruudk ruudk deleted the worktree-name-in-branches-list branch March 9, 2026 11:13
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 24, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.59.0` → `v0.60.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

### [`v0.60.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.60.0)

[Compare Source](jesseduffield/lazygit@v0.59.0...v0.60.0)

<!-- Release notes generated using configuration in .github/release.yml at v0.60.0 -->

#### What's Changed

##### Enhancements 🔥

- Rename "Copy commit hash to clipboard" to mention it's an abbreviated hash by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5331](jesseduffield/lazygit#5331)
- Hide the "Fetching..." status of the auto-fetch when bottom line is hidden by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5321](jesseduffield/lazygit#5321)
- Allow removing lines from patch directly by [@&#8203;jesseduffield](https://github.com/jesseduffield) in [#&#8203;5277](jesseduffield/lazygit#5277)
- Filter file views rather than search by [@&#8203;jesseduffield](https://github.com/jesseduffield) in [#&#8203;5273](jesseduffield/lazygit#5273)
- Show branch name and detached HEAD in worktrees tab by [@&#8203;ruudk](https://github.com/ruudk) in [#&#8203;5339](jesseduffield/lazygit#5339)
- Add backward cycling support for log view (using `<shift>-a` on status page) by [@&#8203;zaakiy](https://github.com/zaakiy) in [#&#8203;5346](jesseduffield/lazygit#5346)
- Show worktree name next to branch in branches list by [@&#8203;ruudk](https://github.com/ruudk) in [#&#8203;5340](jesseduffield/lazygit#5340)

##### Fixes 🔧

- Fix matching of lazygit-edit URLs without line numbers by [@&#8203;danielwe](https://github.com/danielwe) in [#&#8203;5311](jesseduffield/lazygit#5311)
- Fix [#&#8203;5302](jesseduffield/lazygit#5302): Create .git/info directory before writing exclude file by [@&#8203;cobyfrombrooklyn-bot](https://github.com/cobyfrombrooklyn-bot) in [#&#8203;5325](jesseduffield/lazygit#5325)
- Fix off-by-one error when calculating popup panel dimensions by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5312](jesseduffield/lazygit#5312)
- Properly disable clicks in inactive views behind popups by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5313](jesseduffield/lazygit#5313)
- Enable `{` and `}` to change diff context size in branches and tags panels in diffing mode by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5258](jesseduffield/lazygit#5258)
- Fix diff display of custom pagers after screen mode change by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5349](jesseduffield/lazygit#5349)

##### Maintenance ⚙️

- Bump github.com/cloudflare/circl from 1.6.1 to 1.6.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5323](jesseduffield/lazygit#5323)

##### Docs 📖

- Fix typo: MacOS to macOS by [@&#8203;04cb](https://github.com/04cb) in [#&#8203;5335](jesseduffield/lazygit#5335)

##### I18n 🌎

- Update translations from Crowdin by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5352](jesseduffield/lazygit#5352)

##### Other Changes

- Add Terra as an alternative Fedora install method by [@&#8203;Owen-sz](https://github.com/Owen-sz) in [#&#8203;5281](jesseduffield/lazygit#5281)

#### New Contributors

- [@&#8203;Owen-sz](https://github.com/Owen-sz) made their first contribution in [#&#8203;5281](jesseduffield/lazygit#5281)
- [@&#8203;danielwe](https://github.com/danielwe) made their first contribution in [#&#8203;5311](jesseduffield/lazygit#5311)
- [@&#8203;cobyfrombrooklyn-bot](https://github.com/cobyfrombrooklyn-bot) made their first contribution in [#&#8203;5325](jesseduffield/lazygit#5325)
- [@&#8203;04cb](https://github.com/04cb) made their first contribution in [#&#8203;5335](jesseduffield/lazygit#5335)
- [@&#8203;zaakiy](https://github.com/zaakiy) made their first contribution in [#&#8203;5346](jesseduffield/lazygit#5346)

**Full Changelog**: <jesseduffield/lazygit@v0.59.0...v0.60.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My42MS43IiwidXBkYXRlZEluVmVyIjoiNDMuNjEuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants