Dealing with Production and Development Git Repositories
I use Git for managing my source code. I usually have 3 Git repositories, Local repository, Server repository and Production repository.
This is a development version of your project. Here you develop new feature and tests things.
This is a server repository. Any developer push to this repository and the production pulls from it.
This repository holds the production repository. You should not develop to this repository just pull the changes from Server repository.
Github is very great for hosting public projects and sharing codes. But what if you want to host it and don’t want to share codes publicly. Then you need to host your codes.
Hosting git repository is very easy. Here are the steps:
First you need to create bare repository “my_project.git”
git clone --bare my_project my_project.git
Put the bare repository to the server.
scp -r my_project.git [email protected]:location/for/my_project.git
Add group write permissions
ssh [email protected] cd location/for/my_project.git git init --bare --shared
If you want to make the bare repository writable by specific group: Fix the folder permission and assign user to that group
chgrp -R group_name folder_name
To get a local repository to work with:
git clone [email protected]:location/for/my_project.git
If you have a production code running on the server and a local code for development.
You will have 3 repositories:
- development repository
- production repository
- bare repository
The scenario for deployment would be:
- write your codes in the development repository
- push your code from development repository to bare repository
- pull codes from bare repository to production repository
The steps for the scenario:
So on the development system run
git commit git push origin
Then on the production system run:
git pull origin
Reference: Git on the Server