Home > database >  How can I safely switch Git branches while a Jupyter notebook is running on one branch?
How can I safely switch Git branches while a Jupyter notebook is running on one branch?

Time:12-17

When I am running a Jupyter Notebook (under VSCode) that is constantly producing output in one Git branch, would I run into conflicts when I switch the Git branch to meanwhile work on another file/notebook?

I experienced once that my Jupyter cells kind of disappeared when I checked again, so I wonder whether this was a bug, me doing some accidental deletes or due to the branch switching.

CodePudding user response:

That's a job for git worktree.

Let some job run on your repo checked out on some branch.

Add a new worktree to the repo with git worktree add <other_dir> and git will recreate the file structure of the repo in <other_dir>

Then cd to the new worktree and checkout any branch of the repo without interfering with whatever is running in the main worktree.

CodePudding user response:

You can use git stash to save your work on your current branch aside and not get conflicts and change branch. Then when you come again on your first branch to get all your work from befor you can just use git stash pop.

  • Related