Taha's picture
Hi i'm new to linux and redmine in general. I need help seting up a new git repository for a new git project. if someone could point me to the right direction in how to do this it will be very helpful. thank you
Dan Robertson's picture

The Redmine appliance comes with Git already installed.  You would just need to set up a new repository with git init and then tell your Redmine project where the repo is at.  Repositories are stored in /srv/repos.  Is there something specific you need help with?  If you need help with learning git, I would suggest:

Taha's picture

Well basically thats what im looking for how to set up the git repository in TKL Redmine, like the procedure of how to setup that git repo under linux. Coming from windows and getting into linux for the first time is quite a jump specially when working in console. So basically yeah im just looking for how to setup the git repo so i can link it to redmine and upload source to that repo.

Thanks for the links above i'll look through them. but basically i need help with 2 things 1) being the setup of the git repo and 2) uploading the source on the git repo.


Dan Robertson's picture

Here's a quick rundown

Log into your server using SSH.

Go to the /srv/repos directory.  I believe there is a git folder there that you can go into and see the sample repo:  cd /srv/repos/git

Create a repo with the git init command:  git init <repo name>    This will create a directory and also the .git subdirectory.  Go into your repo: cd <repo name> 

Create a file:  touch readme

Add it to the repo:  git add readme

Commit the changes:  git commit -m "Initial commit"

Now log into Redmine and into the project.  Go to Settings then Repository.

Select Git as the SCM and input the path to your git directory:  /srv/repos/<name>

Save it then go to the Repositories tab.  You should see your repo with the readme file you created.

To check out a copy on your workstation you can use the git clone command:  git clone git://<address>/git/<name>

After you make changes and commit you can push it back:  git push origin master

After you push you will need to go into the Repositories tab to have Redmine update it.  There are ways to schedule this or add it into a hook, but I haven't personally set one up.

You should read those resources to understand more about git.  I've been using it for a little while and keep learning new things.

Taha's picture

Thanks for the info... but now i'm getting this weird error, when i try to clone the repository.

Initialized empty Git repository in /home/user/RTU_CommLib/RTU_CommLib/.git/
fatal: The remote end hung up unexpectedly

My Redmine is setup properly i can see all my git repositories in there its that that  i can clone the repository

Dan Robertson's picture

It may be an authentication issue.  I usually do all mine via ssh.  You can do something like this:

git clone ssh://<user>:<password>@<server ip address>/git/RTU_CommLib

See if you can access it with the root username and password.

Taha's picture

Thanks that worked out... i just wanted to know one thing.

i committed a file using

git commit -a -m "TEST Commit"

then pushed it back using

git push origin master

so now i can see the file on redmine appear on redmine as being committed but i dont see it physically in the repository when i browse to


is that normal?? i would think that if i can see it on redmine i should also be able to see it physically in the repository.

Dan Robertson's picture

The database is contained in the .git directory.  It contains all the data of all the branches and every commit.  The RTU_CommLib directory contains the database along with what is known as the working tree.  When you push to the git repository, you are updating what is in the database, but the working tree doesn't change.  If you want to have an updated set of files you will need to perform a checkout or a hard reset.  You can make the server do this automatically with a post-receive hook.  Go on the server and create a file called /srv/repos/git/RTU_CommLib/.git/hooks/post-receive if it is not already there.

nano /srv/repos/git/RTU_CommLib/.git/hooks/post-receive

Paste this script in the file:

cd /srv/repos/git/RTU_CommLib
env -i git reset --hard master

This will set your working tree to what is currently in the master branch.  (There are other ways to do what you want, this is just one.)  After you save it you will need to make sure the hook is executable

chmod +x /srv/repos/git/RTU_CommLib/.git/hooks/post-receive

Now the next time you push to your repo on the server, the server will perform a hard reset and the working tree files will match latest commit.

ali's picture

when i try to install visual studion for git, i get this message :

There is a problem with the windows installer package. A program run as part of setup did not finish as expected. COntact your support personnel or package vendor.

any one met this case? thanks in advance

Iván Carrasco's picture

Well, after having read some post with people that have got troubles setting up git, and as i also got some problems, since it was the first time i've used git, i've written this small guide, for creating a repository from the scratch, setting it up, and also setting up your local environment:

Step 1) At TKL Redmine VM console

Change to the directory where the repository will be created, typically:

cd /srv/repos/git/

Create a bare directory

git init --bare --shared redminetest.git 

Steo 2) At your local machine, where you are gonna work locally

This are the steps for setting up your local environment, linked to the newly created repository in your VM

First, let's check out the repository, then perform the initial commit

git clone ssh://root@YOUR_VM_HOST_OR_IP/srv/repos/git/redminetest.git

Enter your root's VM password when prompted and go the newly created directory

cd redminetest

Create a new file

touch test.txt

Add it to your local git env

git add test.txt

Commit it to your local git env

git commit -m "Initial commit"

Commit it to your VM central repository

git push origin master

Step 3) In Redmine Web interface

  1. Login as admin
  2. Pick your project or create a new one
  3. Go to $PROJECT-->Settings-->Repositories
  4. Click on New Repository
  5. In the form
    1. Pick git as SCM
    2. Set "/srv/repos/git/redminetest.git" as Path to repository
    3. Leave the rest of the form as is         
    4. Accept it
  6. A new tab (Repository) should appear now, click on it
  7. The repository should be there, unless you haven't make the initial commit (Step 2). If that's the case, you'll get a 404 error. Do  the initial commit and everything should be fine


Hope this helps


Jeremy Davis's picture

Nice post. I think that we should put that into the docs, perhaps under Tutorials / HOWTOs?

Add new comment