Get started with Git on Ubuntu

Rainesoft Blog   •   March 24, 2017


Today I’m working on setting up a Git server to manage my projects (code repositories). I Followed this link which is very useful. That should basically get you set up and ready to go.

I wanted to add an extra touch and notify my team whenever changes were made to a project (a new push, etc.).

I did some searching online and put together this script;

[code language=”bash”] #!/bin/bash


cd /home/git/repositories
mkdir $1
cd $1
git –bare init
ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
git config hooks.mailinglist ""
git config hooks.envelopesender
git config hooks.emailprefix "[Git]"
> description
echo $2 > description
cd ..
sudo chown -R git:git $1
sudo chmod -R 775 $1[/code]

Basically what this does is;

  1. Navigates to your repositories directory
  2. Creates a sub-directory (your new repository)
  3. Opens the sub-directory and initializes the repository
  4. Enables the email functionality and creates the mailing list of people that will receive notifications (i.e. your team mates)
  5. Gives a description to the repository

So to get the script working, you will save it with a .sh extension and run it like this (assuming you saved it as “”);

./ newrepository “repository description”

Hope this makes life simpler for you when creating a repository. I’m sure it will reduce my tasks when starting a new project.

Comment on ways to improve this!