Reset file permissions when switching branches in Git

I created a Git repository in a folder with a different Linux owner than my user. Only after that I set the group permissions for recording so that my user can make changes and write to Git. However, whenever I switch from branch to main, all write permissions of the group are lost.

I tried to switch to the main branch and, using the root user, make all the files with the record turned on for the group I am in. But when I switch to another branch, all write rights to the group are again lost.

+3
source share
2 answers

I don’t think this is git specific, git will just use the current group and umask to check the files, so if you want your working tree to be a specific group writable by this group, you should either use newgrpto enter the necessary group or recursively set the group bit and setgid in the working tree and make sure your umask excludes the bit for the group entry (e.g. 0002).

+2
source

Git does not track permissions (except the executable flag). Therefore, make sure that umaskyour current user is configured so as not to remove the group record flag from files. Usually it is installed in 022, in your case it should be installed on 002. man umaskfor more details.

0

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


All Articles