Better generated branch names with jj

Lobsters Hottest Tools

Summary

The article presents a template alias for the jj version control system to generate more readable branch names by slugifying commit descriptions, improving usability over the default change ID-based names.

<p><a href="https://lobste.rs/s/r4xf2n/better_generated_branch_names_with_jj">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 05/19/26, 08:45 PM

# Better generated branch names with jj Source: [https://ddbeck.com/notes/jj-git-push-bookmark-template/](https://ddbeck.com/notes/jj-git-push-bookmark-template/) The`jj`version control system generates branch names that leave something to be desired\. Here’s my alternative\. I’ve been using`jj`\([Jujutsu](https://docs.jj-vcs.dev/latest/)\), a Git\-compatible version control system recently\. I’m pretty happy with it\. Today I’m happy with its configurability\. For a number of reasons,`jj`expects and encourages the use of anonymous branches\. But if you push to a Git repository, then the anonymous branch needs a name \(a “bookmark” in`jj`, a “branch” in Git\)\. The`jj`command\-line interface provides a shorthand to push a given change, generating a name automatically\. For example,`jj git push \-\-change xyz`pushes the revision with the ID`xyz`to a Git branch named`push\-xyz`\. As a default, it makes sense to emphasize the change ID, since the`jj`CLI shows and uses those IDs often\. But suppose later on I’m looking at the list of branches on the repository on the GitHub website\. What actual work does`push\-xyz`represent? I cannot and will not remember\. I changed my configuration to fix this\. I wrote a new[template alias](https://docs.jj-vcs.dev/latest/templates/#configuration),`slugify\(\)`, and changed the`git\_push\_bookmark`template to use it: ``` [template-aliases] "slugify(str)" = ''' truncate_end( 65, str.first_line() .replace(regex:'[^[[:alnum:]].]', '-') .replace(regex:'-{2,}', '-') .replace(regex:'\.{2,}', '.') .replace(regex:'(^-+|-+$)', '') .lower() ) ''' [templates] git_push_bookmark = 'slugify(description) ++ "/" ++ change_id.short()' ``` Now, if I run`jj git push \-\-change ozkspkuyzpwu`,`jj`generates a short[slug](https://en.wikipedia.org/wiki/Clean_URL#Slug)\-like name from the change’s description \(the commit message, if you’re coming from Git\)\. In this case, it generates`add\-note\-about\-jj\-bookmark\-templates/ozkspkuyzpwu`\. This is more readable while retaining the link back to the revision IDs that show up in the`jj`CLI\. If I were to push to a repo shared with others, then I would change it put my branches into a namespace for myself: ``` [templates] git_push_bookmark = '"ddbeck/" ++ slugify(description) ++ "/" ++ change_id.short()' ``` One thing I didn’t do is make sure that the branch names are safe for Git\. Git has some awfully[complicated rules](https://git-scm.com/docs/git-check-ref-format#_description)to determine whether a branch name is valid\. I assume that I’ll get an error if my template ever generates an invalid branch name, at which point I’ll have to create a bookmark manually\. If you liked this, then subscribe to get updates on making documentation, tech writing, and docs as code\. When you sign up, you’ll also get[The 30\-Minute Information Rescue](https://ddbeck.com/30m-info-rescue/), a short guide to interviewing subject matter experts when there’s no time to spare\. Subscribe for periodic articles and offers\. I won’t sell, rent, or give away your personal information\. Unsubscribe at any time\. Read my[privacy policy](https://ddbeck.com/privacy/)for details\. Don’t want more email? Subscribe to[my RSS feed](https://ddbeck.com/feed.xml)instead\.

Similar Articles

jj jj jj jj jj

Lobsters Hottest

A blog post demonstrates how to fix the error when accidentally typing 'jj jj' in the jj version control system by creating a recursive alias in the jj config file that passes arguments through using 'util exec --'.

The Git history command deserves more attention

Hacker News Top

The article highlights the new `git history` command with `fixup`, `reword`, and `split` subcommands, which provide atomic and branch-aware editing of commit history, offering benefits similar to jj without requiring a version control switch.

The (Petty) Reason We Didn't End Up Using jj

Lobsters Hottest

Gradle explains why they decided not to adopt Jujutsu (jj) as their primary version control system: jj does not honor .gitattributes, causing persistent phantom modifications on files like gradlew.bat on Windows due to line-ending mismatches. They continue using git worktree instead.

JJ LSP Follow Up

matklad

The author describes how the upcoming LSP 3.18 Text Document Content Request feature enables a less hacky implementation of Magit-style UX for jj (Jujutsu VCS) by providing virtual documents.

jj v0.41.0 is out

Lobsters Hottest

Jujutsu (jj) v0.41.0 is released, introducing updates to the experimental version control system designed for improved usability and conflict handling.