Difference between revisions of "Using git@school"

From Klaus' wiki
Jump to: navigation, search
(Create the remote project)
(Users from your devhost)
 
(6 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
==User creation==
 
==User creation==
 +
 +
We're using gitolite (see [http://www.gitolite.com here]) for further details.
 +
 +
The is a page instructing how to access the git-server [http://gitolite.com/gitolite/users.html here]. Do also read the fine detailed instructions just below here.
 +
 +
===Users from bren===
  
 
'''Note:'''The following instructions requires you to perform them on bren, i.e. log-in to bren.
 
'''Note:'''The following instructions requires you to perform them on bren, i.e. log-in to bren.
Line 19: Line 25:
 
$ cd <your username>
 
$ cd <your username>
 
$ cp ~/.ssh/id_rsa.pub <your username>.pub
 
$ cp ~/.ssh/id_rsa.pub <your username>.pub
$ vi projectname
 
 
</source>
 
</source>
 +
 +
===Users from your devhost===
 +
 +
Your public ssh-key on your devhost can be used for accessing git-server as explained above for bren. Prepare one if you haven't done that already.
 +
 +
<source lang="bash">
 +
$ scp ~/.ssh/id_rsa.pub <your-username>@bren.hih.au.dk:/home/git-server/<your-bren-username>/<your-devhost-username>@<hostname-for-your-devhost>.pub
 +
</source>
 +
 +
Example:
 +
 +
<source lang="bash">
 +
[klausk@klaus-centos5 ~]$ scp .ssh/id_rsa.pub klausk@bren.hih.au.dk:/home/git-server/klausk/klausk@`hostname`.pub
 +
</source>
 +
 +
The `hostname` is a program that executes and returns the local hostname on stdout and is put into the text, so the line on my devhost expands to ''klaus-centos5.bren.hih.au.dk''
 +
 +
===Users from a Windows git program===
 +
 +
Find the public key in the program and prepare a public keyfile as described under [[Putty]]
 +
 +
Use the same naming convension as described above for devhost - be sure to edit the file as described [[http://klaus.ede.hih.au.dk/index.php/Linux_hints#Windows here]].
 +
 +
==Prepare a project repository==
 +
 +
$ vi projectname
  
 
For every <your username> you will of-course put in your login on bren.
 
For every <your username> you will of-course put in your login on bren.
Line 27: Line 58:
  
 
<source lang="text">
 
<source lang="text">
[group <your groupname>]
+
repo <your reponame>
writable = <your projectname>
+
    RW+ = <list of users that shall have read, write and ''add new files access''>
members = <your username>
+
    RW  = <list of logins that shall have read and write access>
 
+
    R  = <list of logins that shall have read access>
[group <your groupname_ro>
+
readable = <your projectname>
+
members = <member names>
+
 
</source>
 
</source>
  
where the last group is not necessary if nobody shall be able to just read the project without being able to write back.
+
following the rules as pointed out on this [http://gitolite.com/gitolite/repos.html page].
 +
 
 +
If your user name on the different machines you use are not the same be sure to add all your user names.
 +
 
 +
'''NOTE:''' Be sure to follow the edit rules with the repo name and on the immediate next line(s) the access '''indented''' as shown above - '''no empty lines between repo name and the users
  
 
You can add several usernames if needed - you should just provide one username.pub file per username in the same directory.
 
You can add several usernames if needed - you should just provide one username.pub file per username in the same directory.
Line 56: Line 88:
 
</source>
 
</source>
  
Now you have an empty git repository containing one empty file ''afile''.
+
Now you have an empty git repository containing one empty file - ''afile''.
  
 
To push the project onto the git-server issue:
 
To push the project onto the git-server issue:
Line 62: Line 94:
 
$ git remote add origin git@git-server:<your-projectname>
 
$ git remote add origin git@git-server:<your-projectname>
 
$ git push origin master
 
$ git push origin master
</source<
+
</source>
  
 
If no errors your project is now master on the git-server and you can push changes or pull earlier versions.
 
If no errors your project is now master on the git-server and you can push changes or pull earlier versions.

Latest revision as of 10:41, 9 October 2013

git is available for you to store and share your projects.

The is a local git-server - a virtual machine running on top of bren. It is known on bren.

User creation

We're using gitolite (see here) for further details.

The is a page instructing how to access the git-server here. Do also read the fine detailed instructions just below here.

Users from bren

Note:The following instructions requires you to perform them on bren, i.e. log-in to bren.

In order to be able to store projects on git-server you need to be created on the server.

If you haven't done it already, you have to create a ssh key-pair - see Linux hints how to create your ssh key-pair.

Next issue this command:

$ cd /home/git-server
$ mkdir <your username>
$ chmod 700 <your username>
$ cd <your username>
$ cp ~/.ssh/id_rsa.pub <your username>.pub

Users from your devhost

Your public ssh-key on your devhost can be used for accessing git-server as explained above for bren. Prepare one if you haven't done that already.

$ scp ~/.ssh/id_rsa.pub <your-username>@bren.hih.au.dk:/home/git-server/<your-bren-username>/<your-devhost-username>@<hostname-for-your-devhost>.pub

Example:

[klausk@klaus-centos5 ~]$ scp .ssh/id_rsa.pub klausk@bren.hih.au.dk:/home/git-server/klausk/klausk@`hostname`.pub

The `hostname` is a program that executes and returns the local hostname on stdout and is put into the text, so the line on my devhost expands to klaus-centos5.bren.hih.au.dk

Users from a Windows git program

Find the public key in the program and prepare a public keyfile as described under Putty

Use the same naming convension as described above for devhost - be sure to edit the file as described [here].

Prepare a project repository

$ vi projectname

For every <your username> you will of-course put in your login on bren.

when the editor opens add these lines:

repo <your reponame>
    RW+ = <list of users that shall have read, write and ''add new files access''>
    RW  = <list of logins that shall have read and write access>
    R   = <list of logins that shall have read access>

following the rules as pointed out on this page.

If your user name on the different machines you use are not the same be sure to add all your user names.

NOTE: Be sure to follow the edit rules with the repo name and on the immediate next line(s) the access indented as shown above - no empty lines between repo name and the users

You can add several usernames if needed - you should just provide one username.pub file per username in the same directory.

Finally you write a mail to klausk (at) iha [dot] dk asking to have the entries created on the git-server. When you receive an email back everything should be working.

Create the remote project

On bren create a project directory in your home directory or below that.

cd into the directory.

Issue:

$ git init
$ touch afile
$ git add afile
$ git commit -m 'a message'

Now you have an empty git repository containing one empty file - afile.

To push the project onto the git-server issue:

$ git remote add origin git@git-server:<your-projectname>
$ git push origin master

If no errors your project is now master on the git-server and you can push changes or pull earlier versions.