Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git diff noindex exclude files

Tags:

git

diff

Does any one how to exclude files when comparing folders with git diff --no-index ? It seems this option

':(exclude)*.min.css'

does not work with no-index (outside working tree)

like image 376
jani_r Avatar asked Nov 25 '18 19:11

jani_r


People also ask

How does git diff work internally?

In fact, it runs it twice, or more precisely, it runs two different internal variations on git diff : one to compare HEAD to the index/staging-area, and one to compare the staging-area to the work-tree. It runs each diff with a request to search for renames, i.e., sets the -M flag (see below).

What does M mean in git diff?

^M represents carriage return. This diff means something removed a Unicode BOM from the beginning of the line and added a CR at the end.

How do I see git diff?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch.


1 Answers

The pathspec :(exclude) and its short form :! or :^ is available only within a Git working tree.

So:

  • either, as commented, you can put it in a (temporary) git local repo (git init . + git add) or
  • you would need to do your git diff --no-index in a find -exec command with exclude directives.
like image 200
VonC Avatar answered Sep 21 '22 00:09

VonC