Q:

Share (push to) git repo without giving write permissions

I'm working on a collaborative project and we've set up a git repo to manage the code. It's on a server I host, shared via ssh (the repo is on /srv/project). The only way I found to share push access to my teammates is creating a new user for each, adding them  to a "project" group, and making the repo directory writable by that group.
This has a disadvantage: if any of my teammates decides to ssh into the server and rm -rf the whole repo, I can't do anything about it. It's not that I don't trust  them, but "better safe than sorry" (also big organizations must have a solution for this issue).
Is there a way to grant push capabilities but no write perms?
Using SSH is a MUST. GitHub  is not acceptable either.
Thanks!

A:

You can have a dedicated account, say with username git, that uses git-shell as its shell instead of bash. That is, change the account in /etc/passwd from this:
git:x:1000:1000::/home/git:/bin/sh

to this:
git:x:1000:1000::/home/git:/usr/bin/git-shell

It is also recommended to use ssh keys for authentication instead of passwords. I took this example from the Pro Git book, where it's explained in more detail:
http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server
If you don't have permissions to modify user accounts (for example on a shared hosting), you can use ssh keys with a command restriction in the ~/.ssh/authorized_keys file, like this:
command="perl -e 'exec qw(git-shell -c), $ENV{SSH_ORIGINAL_COMMAND}'",no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAAB...

This way authorized users can login with ssh, but instead of a regular shell, they will be restricted to git-shell. This is a bit hackish, it's better if you can just change the shell in /etc/passwd.

