Changing branches via `git switch` effectively forces server restarts

I dread opening a notebook and trying to attach a kernel and no syntax highlighting appearing. Effectively, that signals the end of a productive week for me. Be it a Monday or a Saturday.

[W <date> <time> ServerApp] Notebook <notebook> is not trusted :scream: This has made working on parallel experiments an impossible feat.

All I need to reproduce is keep a notebook open, and switch the git branch once or twice. Has anyone made some workaround this issue?

  1. jupyter trust <notebook> “works” (doesn’t fail), but the current running server is not impacted
  2. If jupyter lab server is restarted, everything is golden BUT
  3. Restarting a server is not feasible when there’s a long running kernel I don’t want to kill