Skip to content

FR: Commands to prune branches from git repo when disabling colocation #9965

Description

@jennings

Is your feature request related to a problem? Please describe.

When not using a colocated repository, but the backing repository contains branches (refs/heads/*), they show up as @git bookmarks and cannot be easily removed from jj.

This seems to happen most often after running jj git colocation disable, but it would also be a problem after accidentally running jj git export.

It's error-prone to remove these with git -C $(jj git root) branch -D ... because if somehow jj git import runs afterwards, jj will abandon the commits that are now unreachable (or will have conflicted bookmarks).

Describe the solution you'd like
I think 99% of the time, when disabling colocation, the user wants all heads removed because they plan to never use the Git repo. So, I think jj git colocation disable should automatically remove the branches.

If the user didn't want this, they could run jj git export (which they'll probably be doing often anyway).

Optionally, we could add a jj git export --prune that removes all refs/heads/* from the underlying git repo without abandoning any commits. This supports the scenario of running jj git export in a non-colocated repository.

Describe alternatives you've considered

  • jj git colocation disable --prune-branches: I think pruning is wanted 99% of the time, so if anything this should be --no-prune-branches.
  • jj bookmark delete <name>@git: This doesn't work for other "remote" bookmarks, so I'm not sure that we should make @git a special case.
  • Anything like jj git export-prune or jj bookmark prune-git: These feel like very specialized commands, it may not be worth making them a "full" command.

Additional context

I'm opening an issue for discussion before actually implementing anything.

Related to:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions