Home > OS >  Git name only and patterns
Git name only and patterns

Time:09-22

I have a notebook.ipynb with one cell that has the following code def test( ): return "yes"
and another script.py that has one line of code: test="test"

So I run the following command:

black --$(git diff --name-only -- *.ipynb -- *.py) 

My terminal shows one change on the notebook.ipynb and no change on the script.py

How should I use the command git diff --name-only ?

CodePudding user response:

Following "How to filter git diff based on file extensions?", I would first test the diff command alone:

git diff --name-only -- '*.ipynb' '*.py'
                    ^^^
                only one --

Or:

git diff --name-only -- *.{ipynb,py}

Once that is working, you can include the diff command in your more general command.

  • Related