Skip to content

Switching Branches Keeps Files #843

Open
@mlucool

Description

@mlucool

Description

When switching branches - jupyterlab git should close all open files that are not present in the other branch.

Reproduce

  1. Create branch A
  2. Commit a notebook to it (N1) and leave that notebook open in lab
  3. Create a new branch from A, called B (which now has N1) and switch to B
  4. Create a second notebook (N2) commit that and leave it open in lab (here you are in B with N1/N2 committed and opened in Lab)
  5. Switch to A (either via CLI or UI).
  6. If autosave enabled, wait for it to be autosaved (you can also just save it)
  7. Try to switch to branch B again

This creates an issue because:

  1. Switching branches fails because my untracked file would be overwritten with itself
  2. It makes it easier to get confused

Expected behavior

Any committed file should be closed when switching branches if it is not in the new branch (i. e. if git removes when switching). Ideally this is true both for the CLI and the UI, but I think it's ok to only fix the UI if the CLI variant is too hard/out of scope.

Maybe this is a jupyterlab request, as it could also be thought of as any file removed from disk should close in lab (possible with a warning).

Context

Lab 2.3.0a1
Jupyterlab-Git: 0.23.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions