I am trying to exclude a file (db/irrelevant.php
) from a Git diff. I have tried putting a file in the db
subdirectory called .gitattributes
with the line irrelevant.php -diff
and I have also tried creating a file called .git/info/attributes
containing db/irrelevant.php
.
In all cases, the db/irrelevant.php
file is included in the diff as a Git binary patch. What I want is for the changes to that file to be ignore by the diff command. What am I doing wrong?
The . gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global .
To exit this you can use: :q for exit; :h for help; Note: if you don't want to read the output in pager you can use an ENV variable GIT_PAGER to cat or you need to set core.
Comparing changes with git diffgit diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
Omg, drivers and awk to exclude a lousy file ? Since git 1.9 something you can:
git diff -- . ':(exclude)db/irrelevant.php' ':(exclude)db/irrelevant2.php'
(On Winodws, replace the single quotes '
by double quotes "
.)
Ah, elegance! See the quoted answer and for details this answer by @torek
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With