Git in your runtime
Every Neural Studio runtime ships git and the GitHub CLI (gh), so you can
version your workspace from a terminal or a notebook cell without installing
anything. New repositories start on main.
cd ~/workspace
git init
git add .
git commit -m "first commit"
Sign in to GitHub with gh auth login (a device-code flow — no key to paste),
then gh repo create pushes the repository to your account.
Your workspace is durable storage, so a repository you create there is still
there after the runtime stops. Git credentials live in your home directory,
which is not durable: run gh auth login again on a new runtime, or keep a
token as a Workspace Secret (Settings → Secrets) named for example GH_TOKEN,
reference it from your environment's runtime secrets, and gh picks it up
from the environment variable automatically.
Notebook outputs are stripped from commits
Committing a notebook with its outputs bloats history with images, tracebacks
and execution counters, and makes every diff unreadable. Runtimes therefore
install a system-wide git clean filter for *.ipynb that strips outputs at
git add time:
- code cells are stored with
outputscleared andexecution_countset tonull; - the ipywidgets state blob (
metadata.widgets) is dropped from the notebook and from each cell; - everything else is kept exactly as you wrote it: cell sources, cell metadata (tags, skip flags), and notebook metadata including the kernelspec and your saved cell selections.
The filter only changes what git stores. The notebook file in your workspace is never modified — you keep your outputs; the repository does not. It is idempotent and passes anything that is not a notebook through untouched, and it never fails a commit: if it cannot parse a file, the file is committed as-is.
You can see what will be committed for a notebook with:
git add notebook.ipynb
git show :notebook.ipynb
Opting out
Per user, on this runtime (a global git setting; add it to your workspace setup if you want it on every runtime):
git config --global filter.nbstrip.clean cat
Per repository, which also wins over the runtime default for anyone who
clones it (a repository's own .gitattributes takes precedence over the
system attributes file):
*.ipynb -filter
Prefer your own tool (nbstripout, jupytext)? Declaring its filter in the
repository's .gitattributes replaces the built-in one the same way.
Where the pieces live
| Path | Role |
|---|---|
/opt/ns/nbstrip.py | The clean filter (Python standard library only). |
/etc/gitconfig | filter.nbstrip.clean, filter.nbstrip.smudge, core.attributesFile, init.defaultBranch. |
/etc/ns/gitattributes | *.ipynb filter=nbstrip. |