首页 > 解决方案 > Files in .git folder have wrong permissions after pushing to non-bare repository (receive.denyCurrentBranch updateInstead)

问题描述

Setup

I have a git repository on my work computer and a clone on my laptop. I set git config receive.denyCurrentBranch to updateInstead. This way I can push from my laptop to my work computer and git automaticaly updates the local files in my work directory there.

My work computer uses a NFS file system and per defaut everyone in the group has read permissions.

On my laptop, I have the remote configured with username@computer:/home/path/to/git

My colleges have their remote configured using /path/to/home

The problem

Whenever I push to this non-bare repository, updated files in the .git folder (.git/refs/heads/master, .git/objects/...) get read permission for me, but not for the group. By default and before pushing, they had read permission for the group as well.

This way, my colleges cannot pull from my repository and get weird error messages.

The question

Is there some setting that I can change to change this behavior? Is this the intended behavior? Or is there no solution to this except for filing a bug/ feature request with the git developers?

标签: git

解决方案


Remote URL username@computer:/home/path/to/git means that you use SSH, not NFS. You need to configure umask on the server side; try to edit it in /home/username/.bash_profile at the work computer.

You're also recommended to set

git config core.sharedRepository 0640

in the shared repository to make git to use this fixed umask instead of users' umask.

See https://git-scm.com/docs/git-config#git-config-coresharedRepository


推荐阅读