On Mon, Dec 03, 2018 at 07:45:06AM -0800, chiahunglin....@gmail.com wrote:

[...]
>     git remote set-url origin https://...
> 
> git complains `error: could not lock config file .git/config:
> Permission denied`. All solutions found online suggest changing with
> `chown`. But that's not the case because all dirs under the directory
> with user and group configured are with my account e.g. 
> 
> My account is <my user>, and group is <my group>. Source dir called
> my-project is stored under /path/to/parent-project.
> 
> `ls -alh` parent project dir shows
> 
>     drwxrwxr-x 16 <my user> <my group> 4.0K Sep 27 11:17 <parent-project>
> 
> And ls -alh my-project shows   
> 
>     dr-x------ 10 <my user> <my group> 4.0K Sep 27 10:57 <my src directory>   
>  

These permissions mean <my user> is able to read "r" the contents of the
directory (the list of entries it contains) and make that directory
current, and traverse it - that's what "x" gives when is set on
directories.

As you can see, there's no write, "w", permission which allows to "write
into the directory" - and creating/removing a file is writing into it.

"The trick" about why "w" is needed has to do with the way to make a
so-called "atomic" update of the contents of a file on a Unix system: to
do that, you read the file, _write a copy of it_ with the updated
contents aside with the original one but with a different name and then
perform the rename(2) syscall which renames the file with the updated
contents "over" the original one. rename(2) is guaranteed to be atomic
so that it either happens successfully or fails completely.

>     -r-x------  1 <my user> <my group>   23 Sep 27 10:57 <my file in git>

This also won't allow _you_ to update the said file.
Dunno if this is intentional or not, just pointing out.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to