nb
nb copied to clipboard
Handling default git branch names
When setting up a new notebook and adding a remote, it may be useful to be able to specify the branch name as part of nb remote set
, or to be able to set a default in the configuration somewhere. I've set up my local Git server to default to main
instead of master
, and GitHub has changed its default for new repositories too. This can be worked around with by running nb git branch -m master main
after setting the remote, but a notebook-level or global-level configuration option would probably help as more Git repos default to main
.
I just experienced the same thing.
In my case, I also needed to run:
$ nb git push origin main
I'm working my way toward addressing this. In the meantime I've been keeping this in mind over the past few months and nb
should be branch-name agnostic, though as you noticed there isn't a lot of branch handling logic yet.
For reference, nb
uses git init
when creating notebooks, so the default branch name should reflect the setting in git config --global init.defaultBranch
. When syncing, nb
just uses the the current branch name.
if your using nb sync
on a remote that your adding for an existing notebook that already exists, nb
still complains that it can't find the master
branch. keep having to use nb git branch -m master main