logoalt Hacker News

arccytoday at 10:27 AM0 repliesview on HN

i too work with worktrees (jj workspaces) and prs (requires branches). it's easier if you give up choosing the name of your branch, and instead rely on finding things by description or your workspace name.

for prs, I usually start with a single commit, so `jj git push -c` will auto create a named branch based on the change id. And i have template like the following to push to the same branch if i decided to stack commits rather than rewrite:

    branch-push   = ["util", "exec", "--", "sh", "-c", """
    name="$(jj log --no-graph --no-pager --color=never -r 'fork_point(@ | trunk())+ & fork_point(@ | trunk())..@' -T '"push-" ++ change_id.short()')"
    jj bookmark set -r @- "${name}"
    jj git push -b "${name}"
    """]
you could probably write a similar alias that used your workspace name as the branch name to push to.

and descriptions are slightly nicer than branch names, since they can be longer.