Showing posts with label repo. Show all posts
Showing posts with label repo. Show all posts

Sunday, November 15, 2009

Creating gitosis repository and adding users to projects

Cont from, Previous post

Adding new repo(gitosis.conf)


Administrator is the only authenticated user for this (In according to previous posts in my case it's janaka). First administrator can log to the server which runs git.First it is better to add the repository on the conf file. And you can add users for this repository.
janaka@versioncontrol~/gitosis-admin $ vi gitosis.conf

Your conf file look like this,
[gitosis]                  

[group gitosis-admin]
writable = gitosis-admin
members = janaka@versioncontrol

Edit it and add new repo, Now it will looks like,
[gitosis]                  

[group gitosis-admin]
writable = gitosis-admin
members = janaka@versioncontrol

[repo my_first_repo]
gitweb = no
description = This could be my first repo
owner = No one else thats me,
daemon = no

Creating a user group


Your conf file look like this,
[gitosis]                  

[group gitosis-admin]
writable = gitosis-admin
members = janaka@versioncontrol

[repo my_first_repo]
gitweb = no
description = This could be my first repo
owner = No one else thats me,
daemon = no

Edit this file and add new group,

[gitosis]                  

[group gitosis-admin]
writable = gitosis-admin
members = janaka@versioncontrol

[group my_users]
writable = my_first_repo
members = janaka@versioncontrol gituser1

[repo my_first_repo]
gitweb = no
description = This could be my first repo
owner = No one else thats me,
daemon = no

gituser1 is the newly added user, his key is named as gituser1.pub on keydir/ directory.
Now you should add this changed gitosis.conf file and update gitosis-admin repository. You can do it by executing following commands.
janaka@versioncontrol~/gitosis-admin$ git add gitosis.conf
janaka@versioncontrol~/gitosis-admin$ git commit -m "Added new repo on conf file"
janaka@versioncontrol~/gitosis-admin$ git push

Then you can create the directory you want and create physical repository.

Creating new repository


Create a directory with naming it on your wish.
janaka@versioncontrol~$ mkdir my_first_repo
Now go into it, Don't forget to add some files before initialize this repo. Otherwise it will not be added as a repository,
janaka@versioncontrol/my_first_repo~$ touch readme
then follow the given commands to initialize the repository,
cd my_first_repo
git init
git remote add origin git@192.168.4.90:my_first_repo.git
git add .
git commit -m "Hai buddies, we added my_first_repo"
git push origin master:refs/heads/master
192.168.4.90-is the server which runs git on it. Now the new repository is created.
This is it, now gituser1 can use the my_first_repo repository. You can check on client machine,
git clone git@192.168.4.90:my_first_repo

On windows client side, If you'r only using command prompt, why don't you go for TortoiseGit to make life easier. TortoiseGit is a graphical tool to access git repository. Follow

"Graphical controls for Git windows clients"

link and study it.

Saturday, November 14, 2009

(Tortoisegit + Gitosis + msysgit) configuring - Adding windows users and creating repo

Cont. from previous post
Now you are ready to add users to the server.
It is not that much hard to add ubuntu users.
You just have to install git-core and by adding keys to the key directory. You can add users. If you are a windows user you have to do some installations. There are few ways to access repositories as windows user.

Clients using who use command prompt


First you should download msysgit from here and run the exe. Assume you downloaded the full version.

Give the path as your wish.
To run git commands at anywhere from your command prompt, define a path variable on environment variables Right Click on My Computer => Properties => Advanced => Environemnt Variables => Edit or New give the variable name as "PATH", and variable value "C:\msysgit\msysgit\bin", the bin folder of the msysgit installed. And add the "C:\msysgit\msysgit\mingw\bin" path also, that means, variable value will looks like, "C:\msysgit\msysgit\bin;C:\msysgit\msysgit\mingw\bin"

Then go to start => run => cmd type git and press enter. You will get result like,

Now you are ready to use git.

Adding user


First of all you have to create a key pair for your self. Get the command prompt and navigate to the msysgit folder to create .ssh directory.
C:\msysgit\msysgit\> mkdir .ssh

You are not allowed to create folders beginning with "." by right click => New => folder. So that it should be created this way.

Now navigate into the .ssh folder. We are going to create key pair.
C:\msysgit\msysgit\.ssh> ssh-keygen 
give id_rsa for the key name.
Following result will be shown.
C:\msysgit\msysgit\.ssh>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa): id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
92:0c:83:16:16:14:04:51:30:42:da:5d:df:fd:fb:15 Janaka@XPWINDOWS7

Now you need to transfer the public key to the server where your gitosis administrator belongs. With previous posts, you might remember my username at version control is janaka. Following command will carry your key to that server's keydir directory.On my command prompt,
C:\msysgit\msysgit\.ssh>scp id_rsa.pub janaka@192.168.4.90:gitosis-admin/keydir/gituser1.pub
(Assume 192.168.4.90 is the server that installed gitosis) using this command or anyhow you can copy your key to keydir/ directory.
Don't change the names of the public and private keys of the(id_rsa,id_rsa.pub) on your local machine. Keep it as it is on .ssh folder.
Now the administrators part,
Admin should allow this key to copy to server and rename it. When renaming, keep remember to give the same name that you are planing to add in .conf file. If new user is gituser1, then public key should be renamed to gituser1.pub on server.
On the server, admin should enter the this user into a user list of gitosis.conf file. You can see how to create new repository and work groups in this link.
On gitosis.conf,
[group myteam]
members = gituser1
writable = my_current_project
member should be the name of the added public key(without .pub) and writable is the repository which are writable by this team. Group name is myteam.
Now administrator should add these key file and changed gitosis.conf file and push it to git user. Actually administrator just cloning the gitosis-admin part from the "git" user and after changes pushing it back. Here are the commands for admin,
janaka@versioncontrol~$ git clone git@192.168.4.90:gitosis-admin
janaka@versioncontrol~$ cd gitosis-admin
janaka@versioncontrol~/gitosis-admin $ git add keydir/gituser1.pub
janaka@versioncontrol~/gitosis-admin $ git add gitosis.conf
janaka@versioncontrol~/gitosis-admin $ git commit -a -m "Added gituser1 as a new user"
janaka@versioncontrol~/gitosis-admin $ git push
Now on the client side (gituser1) can check whether he had successfully added. On command prompt he can try to add a clone.
 
C:\MyFolder> git clone git@192.168.4.90:my_current_project

If it imported my_current_project folder without asking any password for git user it is successfully worked. Issued can be occured,
  • Ask a password for git user- your keys are not matching recreate the key pairs and install keys accurately.

  • Giving no permissions error- You have not been added successfully for that group on gitosis.conf file. Reedit the conf file.

Widows clients using Gitosis

You can find post regarding this from here

Creating new repository and adding permission groups

will be discussed here