title: On win7, cygwin and git bash have different ideas about a file or folder's permission
body: <p>In Cygwin, I set the permission of a folder "tmp"</p>
  
  <pre><code>$ chmod 600 tmp
  
  $ ls -ld tmp
  drw-------+ 1 leecy Users 0 Aug 15 10:56 tmp
  </code></pre>
  
  <p>But Git Bash (from Git for Windows) gets a different idea
  of the permission:</p>
  
  <pre><code>$ ls -ld ~/tmp
  drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 /c/cygwin64/home/leecy/tmp/
  </code></pre>
  
  <p>I have researched, read, and tried out the suggestions (<code>chgrp</code>, <code>chown :Users</code>,  <code>setfacl</code>, etc) from the following posts but still could not find a solution:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/25730041/updating-file-permissions-with-git-bash-on-windows-7">Updating file permissions with git-bash on Windows 7</a></li>
  <li><a href="https://stackoverflow.com/questions/17091972/chmod-cannot-change-group-permission-on-cygwin">chmod cannot change group permission on cygwin</a></li>
  <li><a href="https://superuser.com/questions/397288/using-cygwin-in-windows-8-chmod-600-does-not-work-as-expected/876913#876913">Using Cygwin in Windows 8, chmod 600 does not work as expected?</a></li>
  <li><a href="https://superuser.com/questions/778313/cygwins-chmod-behaves-as-working-but-it-does-not-work">cygwin's chmod behaves as working, but it does not work</a></li>
  </ul>
  
  <p>By the way, this problem is believed to be the reason why my <code>git clone</code> operation
  (which uses SSH) has recently stopped working.  In the above I am
  demonstrating the problem with a test folder <code>tmp</code>, but in real life
  the folder is actually my <code>.ssh</code> and my <code>git clone</code> recently started 
  failing with an error of:</p>
  
  <pre><code>$ git clone ...
  Cloning into 'foo'...
  Bad owner or permissions on /home/leecy/.ssh/config
  fatal: Could not read from remote repository.
  </code></pre>
  
  <p>There may be some recent change related to the Windows Domain 
  set up (done by the corporate IT people) that is related to this
  problem -- the problem started to surface after that change.</p>
  
  <p>Versions:</p>
  
  <pre><code>Cygwin: 2.8.2(0.313/5/3)
  Git Bash: git version 2.14.1.windows.1
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>Thanks for the suggestion by Doug Henderson (see it in the comment).<br>
  I tried using the command <code>setfacl -b -k</code>, it did remove
  the extra non-standard POSIX permissions, but it did not
  solve the problem.</p>
  
  <p>Before using <code>setfacl -b -k</code></p>
  
  <pre><code>$ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: Users
  user::rw-
  group::---
  other:---
  default:user::rwx
  default:group::r-x
  default:other:r-x
  </code></pre>
  
  <p>After using <code>setfacl -b -k</code></p>
  
  <pre><code>leecy@USLEECY-C1 ~
  $ setfacl -b -k tmp
  
  leecy@USLEECY-C1 ~
  $ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: Users
  user::rw-
  group::---
  other:---
  </code></pre>
  
  <p>But that did not help</p>
  
  <p>cygwin:</p>
  
  <pre><code>$ ls -ld tmp
  drw------- 1 leecy Users 0 Aug 15 10:56 tmp
  </code></pre>
  
  <p>Git Bash:</p>
  
  <pre><code>$ ls -ld tmp
  drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <p>Using <code>getfacl</code> I examined closely what group the file is in, and
  indeed <code>cygwin</code> and <code>git bash</code> have two different ideas</p>
  
  <p>Cygwin</p>
  
  <pre><code>$ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: Users
  user::rw-
  group::---
  other:---
  </code></pre>
  
  <p>Git Bash</p>
  
  <pre><code>$ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: 1049089 &lt;unknown&gt;
  user::rwx
  group::r-x
  other:r-x
  </code></pre>
  
  <p>The number <code>1049089</code> may mean <code>Domain Users</code> in my system, but
  this number seems to be understood by <code>cygwin</code> but not <code>git bash</code>.
  I said that because my cygwin <code>/etc/group</code> has a line like this 
  (this file was not there originally, I created it using the command
  <code>mkgroup  -l -d &gt; /etc/group</code> as suggested in this <a href="https://stackoverflow.com/a/38048219">post</a>)</p>
  
  <pre><code>Domain Users:S-1-5-21-1593251271-2640304127-1825641215-513:1049089:
  </code></pre>
  
  <p>I also tried the command <code>chgrp</code> and <code>chown</code>.  Both ran without error,
  but is not taking effect (the number <code>545</code> is the group id for <code>Users</code>
  that <code>cygwin</code> (but not <code>git bash</code>) understands)</p>
  
  <p>No effect of <code>chgrp</code></p>
  
  <pre><code>$ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: 1049089 &lt;unknown&gt;
  user::rwx
  group::r-x
  other:r-x
  
  $ chgrp 545 tmp
  
  $ ls -ld tmp
  drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
  
  $ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: 1049089 &lt;unknown&gt;
  user::rwx
  group::r-x
  other:r-x
  </code></pre>
  
  <p>No effect of <code>chown</code>    </p>
  
  <pre><code>leecy@USLEECY-C1 MINGW64 ~
  $ chown leecy.545 tmp
  
  leecy@USLEECY-C1 MINGW64 ~
  $ ls -ld tmp
  drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
  
  leecy@USLEECY-C1 MINGW64 ~
  $ getfacl tmp
  # file: tmp
  # owner: leecy
  # group: 1049089 &lt;unknown&gt;
  user::rwx
  group::r-x
  other:r-x
  </code></pre>