You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WARNING: git-filter-branch has a glut of gotchas generating mangled history
rewrites. Hit Ctrl-C before proceeding to abort, then use an
alternative filtering tool such as 'git filter-repo'
(https://github.com/newren/git-filter-repo/) instead. See the
filter-branch manual page for more details; to squelch this warning,
set FILTER_BRANCH_SQUELCH_WARNING=1.
Apparently git-filter-repo is a python tool that can run python code directly on the text objects.
Like so (found here, edited so it works for my case)
git filter-repo --path-glob '**/*.ipynb' --blob-callback '
import json
try:
notebook = json.loads(blob.data)
cleaned=False
if (type(notebook) is dict) and ("cells" in notebook) and type(notebook["cells"]) is list:
for cell in notebook["cells"]:
if type(cell) is dict and "outputs" in cell and cell["outputs"]:
cell["outputs"] = []
cleaned=True
if cleaned:
print("cleaned")
blob.data = (json.dumps(notebook, ensure_ascii=False, indent=1,
sort_keys=True) + "\n").encode("utf-8")
except json.JSONDecodeError as ex:
pass
except UnicodeDecodeError as ex:
pass
'
It would be nice to have something like this but doing the rewriting with nbstripout.
The text was updated successfully, but these errors were encountered:
@kynan just did, because I wanted to keep everything in the same interpreter and minimize write/read to disk for performance, it is slightly involved, but still useful information I think.
https://github.com/newren/git-filter-repo is pointed to by git-filter-branch via a scary warning:
Apparently git-filter-repo is a python tool that can run python code directly on the text objects.
Like so (found here, edited so it works for my case)
It would be nice to have something like this but doing the rewriting with nbstripout.
The text was updated successfully, but these errors were encountered: