Git always pulls files that I cannot edit

When I pull out files on OSX using the terminal, I do not have permission to edit by default.
How to change this?


kirkstrobeck:atheycreek kirkstrobeck$ ls -lad ~ . .git drwxrwxrwx 8 kirkstrobeck staff 272 May 24 18:20 . drwxrwxrwx 16 kirkstrobeck staff 544 May 25 10:58 .git drwxr-xr-x+ 92 kirkstrobeck staff 3128 May 24 15:17 /Users/kirkstrobeck 

 kirkstrobeck:~ kirkstrobeck$ umask 0022 

 kirkstrobeck:atheycreek kirkstrobeck$ ls -l total 8 -rwxrwxrwx 1 kirkstrobeck staff 2143 Mar 6 14:49 README.md drwxrwxrwx 4 kirkstrobeck staff 136 May 23 14:45 www kirkstrobeck:atheycreek kirkstrobeck$ 

Note. I ran these terminal commands after fixing the problem with CHMOD, but I do it every time because it pushes the wrong perms.

0
source share
3 answers

When you say that you do not have editing rights - what exactly do you mean?

Note. I ran these terminal commands after fixing the problem using chmod

This means that the result does not help. All of these permissions show:

 kirkstrobeck:atheycreek kirkstrobeck$ ls -lad ~ . .git drwxrwxrwx 8 kirkstrobeck staff 272 May 24 18:20 . drwxrwxrwx 16 kirkstrobeck staff 544 May 25 10:58 .git drwxr-xr-x+ 92 kirkstrobeck staff 3128 May 24 15:17 /Users/kirkstrobeck 

is that you have edit permissions for all of the above - you can expect it if you previously ran chmod -R 777 . in folder.

More relevant permissions are files and folders for the things you are trying to edit. With a specific example of a command, generated errors and permissions of the corresponding files, a concrete answer will come if there is no educated work:

Perms entry is not a git issue

Git does not store folders at all and only saves executable file permissions. you can demonstrate it to yourself as follows:

 [ andy@work :/tmp/so/original]$ git init [ andy@work :/tmp/so/original]$ touch 0700 [ andy@work :/tmp/so/original]$ touch 0600 [ andy@work :/tmp/so/original]$ touch 0500 [ andy@work :/tmp/so/original]$ touch 0400 [ andy@work :/tmp/so/original]$ chmod 0700 0700 [ andy@work :/tmp/so/original]$ chmod 0600 0600 [ andy@work :/tmp/so/original]$ chmod 0500 0500 [ andy@work :/tmp/so/original]$ chmod 0400 0400 [ andy@work :/tmp/so/original]$ git add * [ andy@work :/tmp/so/original]$ git commit -va [master (root-commit) a304e1b] adding files with the named permissions 0 files changed create mode 100644 0400 create mode 100755 0500 create mode 100644 0600 create mode 100755 0700 [ andy@work :/tmp/so/original(master)]$ ls -la total 12 drwxr-xr-x 3 andy users 4096 May 28 14:51 . drwxr-xr-x 3 andy users 4096 May 28 14:48 .. -r-------- 1 andy users 0 May 28 14:48 0400 -rx------ 1 andy users 0 May 28 14:48 0500 -rw------- 1 andy users 0 May 28 14:48 0600 -rwx------ 1 andy users 0 May 28 14:48 0700 drwxr-xr-x 8 andy users 4096 May 28 14:51 .git 

The file permissions given above (with ls -la ) include both numbers (file names) and reading, writing, and perms (on the left). Only two files 0500 and 0700 have executable permissions.

 [ andy@work :/tmp/so/checkout]$ git init Initialized empty Git repository in /tmp/so/checkout/.git/ [ andy@work :/tmp/so/checkout]$ git pull ../original/ remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From ../original * branch HEAD -> FETCH_HEAD [ andy@work :/tmp/so/checkout(master)]$ ls -la total 12 drwxr-xr-x 3 andy users 4096 May 28 14:52 . drwxr-xr-x 4 andy users 4096 May 28 14:52 .. -rw-r--r-- 1 andy users 0 May 28 14:52 0400 -rwxr-xr-x 1 andy users 0 May 28 14:52 0500 -rw-r--r-- 1 andy users 0 May 28 14:52 0600 -rwxr-xr-x 1 andy users 0 May 28 14:52 0700 drwxr-xr-x 8 andy users 4096 May 28 14:52 .git [ andy@work :/tmp/so/checkout(master)]$ 

The above indicates that checkout has default permissions for files (those dictated by umask ), with the addition of an executable file if it was executed as an executable file.

The knowledge above should help you focus on where the real problem lies.

Fix file permissions

If your check has incorrect permissions, you can correct them with the following command:

 # make sure all files are owned by you sudo chmod -R andy:users . # reset to default permissions sudo find . -type d -exec chmod 0755 {} \; -or -type f -exec chmod 0644 {} \; 

Double check that for the files mentioned in any error message you have; now the file permissions are 0644, and the folder is 0755.

With file fixes fixed, you should be good to go.

Please note that you need executable permissions for folders in order to be able to find and manage content. If you don't have the perms executable in the folder, you will get permission errors doing almost anything in it. But, again, git does not save folders at all, it is not git-related if this is a problem.

If this made any changes to your repo, you can transfer them using:

 git commit -am "Resetting file permissions to their default values" 

It will only be making changes to the executable property of the files, and this is just a cleaning step - not fixing anything that could cause rights issues for another user checking the repo.

Ignoring file permissions

If you want your check to completely ignore the permissions that apply to your design, you can use:

 git config core.fileMode false 

this way git will not consider changes to file permissions that you apply to your design as commit changes - but this is unlikely to be relevant given the information available.

+6
source

git works according to your umask settings. The working directory permissions that git handles are executable bits. If you cannot write, you must establish that your umask set very restrictive, for example, 0277 will remove w for itself and rwx for the group and others.

Try running umask to find out what you are currently configured for, and umask 022 to set the typical setting ( 022 = take away w for the group and others).

+2
source

Try checking core.sharedRepository, this can be set so that umask is not the default for permissions:

From git -config (1):

When a group (or true), the repository becomes available between several users in the group (make sure that all files and objects are written to groups). When everything (or the world or everything), the repository will be readable by all users, in addition to being compatible with groups. When umask (or false), git will use the permissions specified by umask (2). When 0xxx, where 0xxx is an octal number, the files in the repository will have this value. 0xxx will override the umask value for users (while other parameters will only override the requested parts of the umask value for users). Examples: 0660 will make a read and write repo for the owner and group, but not available to others (equivalent to a group, unless umask is, for example, 0022). 0640 is a repository that is readable by groups but not accessible by groups. See git -init (1). False by default.

So,

git config core.sharedRepository all

Turn so everyone gets access.

+1
source

Source: https://habr.com/ru/post/1482431/


All Articles