Skip to content

Instantly share code, notes, and snippets.

@Treborium
Created August 4, 2023 07:59
Show Gist options
  • Save Treborium/fda10b406b36ec8fe8143146b4863614 to your computer and use it in GitHub Desktop.
Save Treborium/fda10b406b36ec8fe8143146b4863614 to your computer and use it in GitHub Desktop.
Show modified files in git repository
git diff --name-only --diff-filter=ACMRT | grep -E '.*\.schema\.json$'
@Treborium
Copy link
Author

This command will output a list of files that have been added, copied, modified, renamed, or had their type changed in the repository, and then filter that list to only include files that end with .schema.json.

Here's a breakdown of the command:

  • git diff: Shows changes between commits, commit and working tree, etc.
  • --name-only: Shows only the names of changed files.
  • --diff-filter=ACMRT: Filters the output to only include files that have been added, copied, modified, renamed, or had their type changed.
  • |: Pipes the output of the git diff command to the next command.
  • grep -E: Searches for files that match the regular expression.
  • '.*\.schema\.json$': The regular expression that matches files ending with .schema.json.

Possible extensions:

The --exit-code flag will return 1 if there changes to files and 0 otherwise, which is particularly useful for scripting.

git diff --exit-code --name-only --diff-filter=ACMRT | grep -E '.*\.schema\.json$'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment