-1

For a file (I'm not aware that I modified this file) git diff gives me

diff --git a/file.py b/file.py
old mode 100644
new mode 100755

And no other differences. What does this mean? And how could it happened?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 2
    You probably ran chmod +x – jonrsharpe Apr 16 '21 at 12:22
  • 1
    To my experience, it could happen when we browse or edit a file on Windows and the file is on a mounted disk from Ubuntu, if it's not changed by `chmod`. The line endings may be changed too. – ElpieKay Apr 16 '21 at 12:47

2 Answers2

1

This means the *nix permissions changed. Specifically, execute permission for user, group and world was added.

One possible way this might have come about was for someone with sufficient privilege to type:

$ chmod a+x file.py

Another possible incancation:

$ chmod 755 file.py
Mike Slinn
  • 7,705
  • 5
  • 51
  • 85
1

The mode is part of the metadata.

Git was originally made for linux (and by Linus) and supports its permission system.

644 is the permission rw-r--r- (read-write for owner, read for everyone)

755 is the permission rwxr-xr-x (read write execute for owner, read execute for everyone)

In other words, you have just made the file executable.

dan1st
  • 12,568
  • 8
  • 34
  • 67