How to show relative paths in git diff command?

前端 未结 2 984
感情败类
感情败类 2021-01-18 09:33

It works in this way:

MYPC /d/home/project/some/path (master)
$ git diff --name-only --cached
root.txt
some/path/relative.txt

I.e. it shows

2条回答
  •  滥情空心
    2021-01-18 10:14

    So far, I didn't find a way to use relative paths by using git-diff.

    The only way work for me:

    $ git status -s | awk '{print $2}'
    ../../root.txt
    relative.txt
    

    Or

    $ git status -s | cut -c4-
    

    The last approach explained in How can I run "git status" and just get the filenames. . The first one quite similar. :)

    But it'd be good to find non-pipeline way. Seem, there is no way to avoid using --cached. So, mostly it's not an answer.

提交回复
热议问题