Note: If you prefer to use terminal, you may need root access to use the following commands. If necessary, append “sudo” to all commands.
First, login to your remote server using ssh/ftp whatever. In your servers, say git repos are stored in /srv/gitosis/repositories directory (this is the default directory if you used gitosis).
Say, we’re interested in a repo called “myrepo.git” – it’d be available in /srv/gitosis/repositories/myrepo.git location.
Go to this folder. If you’re using terminal, you can type:
Some nice Description
Open file “description” and type whatever you want – text in this file will be sent in email’s subject as PROJECT NAME.
Open file “config” and add folowing text, configure to which addresses email will be sent as:
mailinglist = email@example.com, firstname.lastname@example.org
showrev = "git show -C %s; echo"
emailprefix = "[My Git Repo] "
Save the file. If you’re using terminal, you can open the files for editing using nano <filaname> command. When done editing, press Ctrl + x for exit, then press y for saving, press enter to use original file name for saving the file.
Now go to “hooks” directory & rename the file post-receive.sample to post-receive:
mv post-receive.sample post-receive
Open the file (“post-receive”) for editing. Uncomment the last line by removing the beginning “#”, then save it.
Set Execute Permission on
Following 2 files should be made executable. I’m showing examples by terminal. If you’re using Filezilla/other file browser, make files “executable”, probably by right clicking on the files and clicking something like permission.
chmod 0755 /usr/share/doc/git-core/contrib/hooks/post-receive-email
chmod 0755 post-receive
That’s it! Now whenever someone pushes to the repo, emails will be sent according to the config file you’ve just edited.
Note: If the file “/usr/share/doc/git-core/contrib/hooks/post-receive-email” is missing, you can use following file downloading.