• notice
  • Congratulations on the launch of the Sought Tech site

Solving the problem of default permissions for Git remote warehouses

When multiple people jointly develop and maintain a project, they pull and push each other's entire project files. In order to prevent file permission conflicts during operation, there are two ways to solve the problem:

1.In the remote settings of the local git, multiple people use the same user name when connecting to the remote warehouse, and the user name is the owner of the git remote warehouse

2.When different developers need to use different user names to connect, there will be file permission conflicts.This is because the git repository uses object storage, and each change will add several object files (the specific object files are in /.git/objects) Below), and the newly added object file permission attribute is controlled by the system, the default is 755, that is, non-file owners cannot write (push). Here you need to set the default permissions of the files under the git repository to the same group of users can read, write and execute. The specific method is:

The syntax when initializing the warehouse:

git init --bare --shared[=( false | true |umask|group|all|world|everybody|0xxx)]

If the warehouse is already enabled, change the syntax of the git configuration in the remote warehouse directory:

git config core.sharedRepository [(false|true|umask|group|all|world|everybody|0xxx)]

Practice: Because I need to set the default permission of all newly generated object files under the warehouse to 770, that is, the owner and the same group of users have read and write execution permissions.The code is as follows:

git init --bare --shared=0770 
//When initializing the warehouse,
git config core.sharedRepository 0770
//Configure after it is enabled


Technical otaku

Sought technology together

Related Topic


Leave a Reply