Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude files & directories from git diff --no-index

Tags:

git

git-diff

diff

How do I exclude files & directories from git diff --no-index?

For example, I want to show the differences between two directories project1 & project2 while ignoring their top-level .git directories (project1/.git & project2/.git) and all their .DS_Store files.

like image 781
ma11hew28 Avatar asked Apr 22 '18 17:04

ma11hew28


People also ask

How do I exclude a scanned file?

To exclude files and folders from scans: On the main menu, click Computers > {group} > Configure > Antivirus/Anti-spyware. Click the expand button next to the Exclusions section of the Antivirus/Anti-spyware page. Under Exclusions, make sure that the check box next to Enable Exclusions is selected.


1 Answers

This is not exactly what you asked for, but it might give you the results you want: Add project2 as a remote of project1 and just git diff their HEADs.

git remote add other ../project2/.git
git fetch other

# Perform the diff
git diff other/HEAD

If your project2 is not already a Git repo, you can temporarily make it one (hat tip to Josiah Yoder for his comments):

# Set up project2 repo
cd ../project2
git init
git add .

# Add as remote from project1
cd ../project1
git remote add other ../project2/.git
git fetch other

# Perform the diff
git diff other/master

# Clean up
git remote remove other
cd ../project2
rm -r .git
like image 178
Michael Avatar answered Sep 19 '22 13:09

Michael