Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make git diff ignore permission changes

Tags:

git

diff

I inadvertedly change the permissions of my entire tree and commit that change along with other content changes.

I use something like :

tar -czf deploy.tar git diff --name-only v1 v2

to generate a tar with the modified files between two tags, the problem is that now because of the permissions change almost all my tree is listed as modified.

Is there a way that I could tell git diff to ignore those files which only has the permissions changed?

like image 557
Cesar Avatar asked Jul 20 '10 13:07

Cesar


People also ask

How do I ignore permissions in git?

If you set core. filemode=false then git will ignore execute bit changes, no need to change local permissions.

Do file permissions get pushed to git?

Git Tracks ONLY the Executable Bit of the Permissions for the User Who Owns the File.

Does git ignore whitespace?

We use the git diff -w command to ignore all whitespace differences. It will ignore spaces at the beginning, middle, and end of lines.

What is mode change in git?

It means that the file mode changed from 755 to 644, but the contents were not altered. git diff is exactly what you are looking for - it shows the changes from unstaged files to the last commit. git diff --cached is for staged files. Follow this answer to receive notifications.


2 Answers

This will tell git to ignore permissions:

git config core.filemode false 
like image 112
Daniel Stutzbach Avatar answered Oct 06 '22 00:10

Daniel Stutzbach


Use the -G<regex> option ("Look for differences whose patch text contains added/removed lines that match <regex>.") searching for any changes at all - i.e. .. Permissions-only changes don't match this, so they are ignored.

So: git diff -G.

like image 33
lazysoundsystem Avatar answered Oct 06 '22 01:10

lazysoundsystem