Git (IV)
Create git directory
_$: mkdir -p /srv/git
Create a repository
_$: mkdir -p /srv/git/base.git
_$: cd /srv/git/base.git
_$: git init --shared=true --bare
Give permission to developers
Remember that the group for developers is called develgroup
.
_$: for user in <developer 1> <developer 2> <developer N>
do
usermod $user -aG develgroup
done
_$: chown --recursive root:develgroup /srv/git/base.git
_$: chmod --recursive 2775 /srv/git/base.git
The permissions should be:
/srv/git/base.git root:develgroup 2775
/srv/git/base.git/objects root:develgroup 2775
/srv/git/base.git/objects/XX user:develgroup 2775
/srv/git/base.git/objects/{info,pack} root:develgroup 2775
/srv/git/base.git/{branches,hooks...} root:develgroup 0775
Remove login
We will not allow developers to log into the server, they will only be able to use git. Be careful that none of these developers is also an administrator, because administrators must have ssh access to this server.
_$: for user in <developer 1> <developer 2> <developer N>
do
mkdir /home/$user/git-shell-commands
cp /usr/share/doc/git/contrib/git-shell-commands/list /home/$user/git-shell-commands/
cp /usr/share/doc/git/contrib/git-shell-commands/help /home/$user/git-shell-commands/
chown -R $user /home/$user/git-shell-commands
chmod -R u+x /home/$user/git-shell-commands
done
_$: which git-shell
/usr/bin/git-shell
_$: vipw
user:x:...:/usr/bin/git-shell