astropy-workshop icon indicating copy to clipboard operation
astropy-workshop copied to clipboard

Look into nbstripout to auto clear notebook output

Open pllim opened this issue 6 years ago • 7 comments

All notebooks (including the solutions) should have outputs cleared before being committed to the repo. Any "output" that should not be cleared should be "hardcoded" as markdown text in the notebooks. This is because generated plots in particular eats up unnecessary storage space and is impossible to view as diff.

pllim avatar Dec 15 '19 20:12 pllim

If you have nbstripout installed, this is the scary git command to apply retroactively:

git filter-branch -f --index-filter '
    git checkout -- :*.ipynb
    find . -name "*.ipynb" -exec nbstripout "{}" +
    git add . --ignore-removal
'

adrn avatar Dec 17 '19 16:12 adrn

Ah, I take it back - that will also remove the cell metadata (i.e. "raises-exception" tags)! Hmm...

adrn avatar Dec 17 '19 16:12 adrn

@adrn , I don't mean clean the git history. I meant this for more like a cleaner repo going forward.

pllim avatar Dec 17 '19 16:12 pllim

Does "clear all outputs" also clear the "raises-exception" tags? :scream:

pllim avatar Dec 17 '19 16:12 pllim

I don't mean clean the git history. I meant this for more like a cleaner repo going forward.

But then we're stuck with the already large, current size of the repo...

Does "clear all outputs" also clear the "raises-exception" tags? 😱

No, it shouldn't!

adrn avatar Dec 17 '19 16:12 adrn

I think it is easier to squash and force push to master than to do some filter-branch magic. :fire:

pllim avatar Dec 17 '19 16:12 pllim

Also, if you must... https://git-scm.com/docs/git-filter-branch#_warning, which suggests https://github.com/newren/git-filter-repo/

pllim avatar Dec 24 '19 20:12 pllim