Can one avoid tracking the notebook python version in git?

When I run a Jupyter notebook without changing any code, it still shows a git diff if a newer Python version is used to run the notebook. This is due to the Python version being tracked in the notebook metadata.

To avoid these unnecessary diffs, I’d like to know:

  1. Is it possible to prevent tracking the Python version in the notebook metadata?
  2. Can the Python metadata be fixed to "version": 3" to help reduce clutter in the diffs?

Here’s a screenshot for reference:

When comparing with nbdime you can ignore specific metadata fields Configuration — nbdime 4.0.1 documentation

The contents of the metadata is defined by the kernel which you are using, not by Jupyter applications themselves; in this particular case by ipykernel:

I do not find the version useful (but certianly there are many who do!) and codemirror_mode surely is some very outdated artifact of the past. It might be worth opening an issue on ipykernel to make inclusion of version configurable and maybe another one to clean up the unused metadata fields.

1 Like

Hi @krassowski !
Thanks a lot for pointing me to these resources!
Just tried making

{
    "Diff": {
      "Ignore": {
        "/metadata/language_info/version": true
      }
    },
    "GitDiff": {
      "Ignore": {
        "/metadata/language_info/version": true
      }
    }
  }

and placed nbdime_config.json in my Jupyter path /Users/jan-hendrik/projects/okapi/.venv/etc/jupyter.

Unfortunately, nbdime diff foo.ipynb still shows the version change, but it was worth a shot. I’ll report that in the * nbdime repo

1 Like