I am using cygwin on Windows 7 professional.

When I create new files such as MyNewFile.java it seems to get default permission set to 755. This is not what I want. I want it to be 644 for regular files.

This is very annoying to have to change permissions every time I create new files outside of the cygwin terminal (cp from cygwin terminal works fine and just keeps existing permissions as expected, even creating new files from inside cygwin works).

Alternatively, is there any way in git to auto-change *.myextension files to always have a specific permission?

If not, is there any way to recursively chmod 644 all *.myextension files recursively under a folder (without affecting folder permissions!)?

  • 1
    For fallback solution, this seems to work: find ./ -type f -name '*.myExtension' -exec chmod 644 {} \;
    – UmaN
    Nov 26 '13 at 10:01
  • 1
    Did you give umask a try? Nov 26 '13 at 10:55
  • umask is 0022. As stated, creating through the cygwin terminal works just fine. The problem occurs when copying files in windows explorer or creating files through e.g. an IDE when programming. This should somehow have something to do with how Windows cygwin treats Windows permissions on folders I suppose...
    – UmaN
    Nov 26 '13 at 12:31
  • 4
    @UmaN: A comment on your comment: there’s no good reason to say find ./ …; find . … works just fine, and if you get in the habit of typing find ./ all the time, one of these days you’re going to type find / -exec rm … (or, equivalently, find /. …) by accident.
    – Scott
    Dec 2 '13 at 22:57
  • 1
    @UmaN, I think Casey Crockett's answer would be the solution, yes? It's backed up by this: cygwin.com/ml/cygwin/2011-02/msg00121.html Jan 1 '16 at 20:45

You need to change the security of the folder within Windows that cygwin is writing to so that it matches your cygwin configuration.

For instance, with default security, I get:

-rwxr-xr-x 1 400 401    0 Jul 29 14:48 New Text Document.txt

After changing security on the folder in Windows, I get:

-rwxr--r-- 1 400 401    0 Jul 29 14:54 New Text Document 2.txt

I have found that the "Everyone" Windows security entry matches up to "other" in the "user group other" listing in the ls command. Remove "Read & execute", leaving only Read for that one to match. The special CREATOR GROUP security entry matched the "group" part for me. When I disabled "Read & execute" and left only Read enabled, all of the directory listing now matched the security of the cygwin created file.


It isn't clear what you're trying to achieve here, but if you're trying to make your cygwin git ignore permissions do this:

$ git config --local core.filemode false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.