0

Currently I am implementing some git hooks that clears my notebook cells when committing. Unfortunately, after committing the script fails (because the files are cleaned and interpreted as new files, which makes sense). Thus, I need to re-do the add & commit command for the exact same files.

Is there any way to automate this? Or at least how can I re-do the same add and commit of the same files again.

knittl
  • 246,190
  • 53
  • 318
  • 364
  • 1
    Not sure I'm following. Can you share an example on how the files look before and after the hook is run? – Mureinik Aug 04 '22 at 09:31
  • Its the same file. In fact, it's a jupyter notebook with cells output, after running the commit command (with pre-commit hook), this command should be executed and the cells should be cleaned. $ jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace PoC.ipynb The command above will save the file with the new changes (without the output of the cells) – Wassim Ben Salem Aug 04 '22 at 09:33
  • What do you mean by "notebook cells"? – Piotr Siupa Aug 04 '22 at 11:30
  • Jupyter notebook. Each cell in jupyter notebook can give outputs and i want to clear these outputs when commiting automatically. – Wassim Ben Salem Aug 04 '22 at 12:20
  • `git add -u & !!` would do that in a bash-like shell – anthony sottile Aug 04 '22 at 13:05

0 Answers0