How to use git diff only for diff.cs files

I tried to differentiate only .cs files, I use: git diff HEAD -./*.cs It just didn't work. Note that there are several cs files in different directories. What is the right team?

Thank!


I am using msysgit in windows. I decided to write a python script for it. There he is:

import os
screenOutput = os.popen('git status').read()
lines =screenOutput.splitlines()
keyword = 'modified:'
cmd = 'git diff HEAD -- '
for line in lines:
    index = line.find(keyword)
    if(index >= 0):
        line = line[index + len(keyword) + 1:].strip()
        if(line.endswith('.cs')):
            cmd += (line + ' ')
os.system(cmd)     

The script displays the output of 'git status', looks for the line with the keyword 'modified:' and gets the changed file names. This is ugly. But it does work. And it can be expanded to handle arguments.

+3
source share
3 answers

I could try git diff HEAD -- $(find . -name '*.cs')for you to give him the full path to everyone. Not sure if this will work, but it can do the trick.

+2

git diff HEAD -- "*.cs" .

+2

git diff **/*.cs .

+1

Source: https://habr.com/ru/post/1751784/


All Articles