3

When I run git status, many files are modified:

$ git status
On branch feature-branch
Your branch is up to date with 'origin/feature-branch'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   file1.txt
    modified:   file2.txt
    modified:   file3.txt
    ...

Is there a way to show that these files only changed their permissions (mode), not contents? I imagine the output would be something like this:

$ git status
On branch feature-branch
Your branch is up to date with 'origin/feature-branch'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   file1.txt (100644 → 100755)
    modified:   file2.txt (100644 → 100755)
    modified:   file3.txt (100644 → 100755)
    ...

I am aware of git diff that will show something like this:

diff --git file1.txt
old mode 100644
new mode 100755

but I'd prefer if git status was showing me this already.


Note: This question seems similar but in that case, git status was not detecting mode changes at all. In my case, files are marked as modified but I'd like to distinguish plain file edits (modifying content) from just changing permissions.

Borek Bernard
  • 50,745
  • 59
  • 165
  • 240

1 Answers1

0

I don't believe git does that. Git keeps these states for the file changes

  •   ' ' = unmodified
  •   M = modified
  •   A = added
  •   D = deleted
  •   R = renamed
  •   C = copied
  •   U = updated but unmerged

Git is smart enough to tell us about renamings, but it keeps quite in the status about mode changes.

But you can make yourself a script that parses the diff of a file and see if the mode has changed, then it changes the output of the default git status.

mnestorov
  • 4,116
  • 2
  • 14
  • 24