Git installation example coupled a redmine forge

Git installation example

Posted By: pmietlicki

Published to Dev on Jul 23, 2017

Architecture

Main repository on a distant server accessible with SSH (central repository)
Local repositories (decentralized) on clients
Automatic update of the production from the main repository (master branch) with "git fetch"

Master access

In our example, the master is on a central forge under redmin inside /var/redmine/git_repositories
Master creation
To install a master, it is very easy just follow information available on http://www.redmine.org/projects/redmine/wiki/.

In brief :

mkdir -p /var/redmine/git_repositories 
groupadd git chown www-data:git /var/redmine/git_repositories 
mkdir TEST.git 
cd TEST.git git --bare init 

Master update from existing project

git clone ssh://pmietlicki@forge/var/redmine/git_repositories/TEST.git 
git add . 
git commit -a -m "commit initiale" 
#Master sync
git push origin master 

To know : you can planify an automatic update of the sources from the production by using "git fetch" inside crontab.

Access rights and git repositories creation inside the master (central repository)

Add users inside the git group :

 usermod -G git pmietlicki 

We can also change the user home to facilitate access to the git repository :

 usermod -d /var/redmine/git_repositories pmietlicki 

Repository access from redmine

Creation of the TEST project in redmine then "Settings" - > "Repositories" -> "New respository" :

SCM : git 
 : checked 
Path to repository : /var/redmine/git_repositories/TEST.git 

Access from Eclipse

Go to "Help" -> "Install New Software..."
Add the repository for your eclipse version (indigo in this example but could be helios, kepler, etc.) : http://download.eclipse.org/releases/indigo
Select git packages from "Collaboration" part

Retrieve a project
Right click in the workspace then "Import"
Select "Git" -> "Projects from Git" then "URI"
Indicate :

 URI : ssh://pmietlicki@forge/var/redmine/git_repositories/TEST.git 

Enter your username and password from the account you have on the server.
Select the "master" branch then "Import as general project"
That's it !
To know
You can change your modifications, then go to the "git" tab and push
To update your sources, you can launch a pull
Useful git commands

#Update local repo 
git checkout -f master git pull 
#Update of your modifications to the central repo
git commit -a -m "commentaire des modifications" 
#or 
git push ssh://pmietlicki@forge/var/redmine/git_repositories/TEST.git 
#To create a new local repo 
git clone ssh://pmietlicki@forge/var/redmine/git_repositories/TEST.git 


Tags: Eclipse, GIT

Archive