Skip to content

feat: add option to keep HEAD on left#80

Open
mbtools wants to merge 3 commits into
hansu:masterfrom
mbtools:head-on-left
Open

feat: add option to keep HEAD on left#80
mbtools wants to merge 3 commits into
hansu:masterfrom
mbtools:head-on-left

Conversation

@mbtools
Copy link
Copy Markdown

@mbtools mbtools commented Apr 3, 2026

Still work in progress

Summary of the issue

When displaying multiple branches, it's possible (for maintainers quite likely) that HEAD is not the most recent commit and the line representing the HEAD branch rendered somewhere in the middle of the branches.

Proposed solution

This PR adds a toggle setting show the HEAD branch always on the left. This allows easy identification of the HEAD branch by position. Since the position becomes stable, the HEAD branch will also maintain a stable color.

Setting: git-graph.repository.commits.headOnLeft: boolean, default false

Demo

Cursor_2941

If the setting is active, the graph adjusts automatically when a different branch is checked out moving the checked out branch to the left (it's a big repo and my system is a bit slow).

Note

Implemented with help from Cursor Composer.

@hansu
Copy link
Copy Markdown
Owner

hansu commented Apr 5, 2026

Nice feature 👍
Let me now if you are done with this.

@mbtools
Copy link
Copy Markdown
Author

mbtools commented Apr 5, 2026

There's still some glitch. I thought is was easier but working on it.

@hansu
Copy link
Copy Markdown
Owner

hansu commented Apr 5, 2026

Yeah for my first test it didn't work as expected.

@mbtools mbtools marked this pull request as ready for review April 25, 2026 14:55
@mbtools mbtools requested a review from hansu as a code owner April 25, 2026 14:55
@mbtools
Copy link
Copy Markdown
Author

mbtools commented Apr 25, 2026

It's working well now for me. I added a demo above. please give it a try.

@hansu
Copy link
Copy Markdown
Owner

hansu commented May 6, 2026

Works ok but one little comment.

Given this example

Screenshot_2026-05-06_11-57-33

With headOnLeft it also touches another line and it looks like the whole graph is mirrored:

Screenshot_2026-05-06_11-57-52

Do you think you can tune that behaviour?

@mbtools
Copy link
Copy Markdown
Author

mbtools commented May 6, 2026

Before: A checkout was treated as a swap: everything on head column traded places with everything on far left. The branch that was leftmost jumped to HEAD’s old column, so the whole column layout looked reshuffled.

Now: We move column fromto (from > to for headOnLeft): that column’s lines/dots/slots go to to, and every column index in [to, from) shifts right by 1. Relative order of the other tracks is unchanged; only HEAD’s track is pulled left through that range.

In your case above, blue and green branches should remain in the same order.

@hansu
Copy link
Copy Markdown
Owner

hansu commented May 6, 2026

It looks now so in my example:

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants