Is there any way to temporarily override attributes in git, similarly to how -c
can be used to override config options?
I would like to call git diff
with a specific custom textconv
command different from the one I normally use.
To make this more concrete: My actual use case is for Jupyter notebooks being edited in vim with the jupytext.vim
plugin.
My normal ~/.gitconfig
contains
[diff "jupyternotebook"]
command = git-nbdiffdriver diff
that sets up nbdime
as a diff driver, and then in ~/.gitattributes
:
*.ipynb diff=jupyternotebook
Now I'd like to have
[diff "jupytext"]
textconv = jupytext --from=ipynb --to=md -o - <
(or something like that) in the git config, and have git diff
act as if
*.ipynb diff=jupytext
was in .gitattributes.
I'd be open to adding the [diff "jupytext"]
section permanently to my ~/.gitconfig
. However, using the "jupytext" driver instead of the default "jupyternotebook" must be temporary, based on a command line option passed to git diff
.
Alternatively, I'd be OK with a command line option to git diff
that forces it to use a different ~/.gitattributes
file that takes precedence over all other .gitattributes
files (e.g. in the same directory).
Ultimately, the command line option is intended to go into the g:gitgutter_diff_args
setting of vim-gitgutter
. I want to force the plugin to convert *.ipynb files differently from the way I would normally want to convert them with nbdime
.
diff.jupyternotebook.command
config? – Dumdumgit -c diff.jupytext.command='jupytext --from=ipynb --to=md -o - <' diff
? – Jumpcommand
instead oftextconv
, so it's a bit tricky, but I suppose it could work. There's no way to disable a configuration option via the command line, right? I'd still be interested in a general way to override.gitattributes
settings. – Trinhtrini