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;
echo CREATING REPOSITORY $1 …
git –bare init
ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
git config hooks.mailinglist "firstname.lastname@example.org email@example.com"
git config hooks.envelopesender firstname.lastname@example.org
git config hooks.emailprefix "[Git]"
echo $2 > description
sudo chown -R git:git $1
sudo chmod -R 775 $1[/code]
Basically what this does is;
- Navigates to your repositories directory
- Creates a sub-directory (your new repository)
- Opens the sub-directory and initializes the repository
- Enables the email functionality and creates the mailing list of people that will receive notifications (i.e. your team mates)
- 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 “thescript.sh”);
./thescript.sh 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!