Git - multiple users using the same working dir: permissions issues in .git meta-files

前端 未结 2 1735
轮回少年
轮回少年 2021-01-30 23:59

The Issue: when multiple users have access to the same working directory, permissions issues can occur in the meta-data if any git operations are p

2条回答
  •  被撕碎了的回忆
    2021-01-31 00:57

    There are a number of ways to address this problem. Personally, I'd recommend the following in your existing repository:

    # Create a group named "gitshare" that will share the repository.
    sudo groupadd gitshare
    
    # Add yourself and as many others as you want to the group.
    sudo adduser "$LOGNAME" gitshare
    
    # Everything else needs to run from the top level of your Git repository.
    cd /path/to/repository
    
    # Add group permissions for *new* modifications to repository.
    git init --shared=group
    
    # Fix permissions for existing repository objects.
    chown -R :gitshare "$PWD"
    chmod -R g+swX "$PWD" 
    

    Obviously, you need to make sure that the users have directory traversal permissions all the way to your repository (e.g. user-private directories may cause problems), and that all team members who need access belong to the repository's shared group. After this initial setup, though, it should "just work."

提交回复
热议问题