3

If I execute:

$ git status

I get

Changes to be committed:
 (use "git reset HEAD <file>..." to unstage)

modified:   ../../resources/dags/BROKEN_DAG.py
modified:   ../../resources/dags/BROKEN_DAG2.py

But

$ git diff --cached --name-only     

returns:

src/main/resources/dags/BROKEN_DAG.py
src/main/resources/dags/BROKEN_DAG2.py

How can I get something like this:

$ git diff --cached --name-only  --some-magic-option
../../resources/dags/BROKEN_DAG.py
../../resources/dags/BROKEN_DAG2.py

?

phd
  • 82,685
  • 13
  • 120
  • 165
ozw1z5rd
  • 3,034
  • 3
  • 32
  • 49
  • https://stackoverflow.com/search?q=%5Bgit-diff%5D+relative+path – phd Mar 10 '20 at 09:41
  • 1
    I found also an alternative way to resolve my problem. 'git rev-parse --show-toplevel' returns the absolute path where the 'git diff --cached --name-only' are relative. So joining the paths I'm able to access the folder within my git hook. – ozw1z5rd Mar 10 '20 at 09:54
  • You should have explained why do you need relative paths because my answer could be different: https://stackoverflow.com/a/957978/7976758, found in https://stackoverflow.com/search?q=%5Bgit-diff%5D+full+path – phd Mar 10 '20 at 10:56

0 Answers0