Jump to content

Git repository on this server: Difference between revisions

From HW wiki
No edit summary
Update to gitolite
Line 1: Line 1:
Note: This article is obsolete as we are switching to [http://github.com/sitaramc/gitolite Gitolite tool] for managing the git repositories. This page will be updated later.
== Repository Types ==
This server can host two types of Git repositories.
;Central repositories: These repositories are managed by [http://github.com/sitaramc/gitolite Gitolite tool] which allows convenient management of developer permissions. Those repositories which are readable by public can be [http://rtime.felk.cvut.cz/gitweb browsed online].
;Personal repositories: Any user with shell access to this server can can create his/her own git repository under his/her home directory and make it public using git protocol.
 
== Central Repositories ==
 
Write access can only be given to users who sent his/her Open SSH public key to the [http://rtime.felk.cvut.cz/~sojka/ administrator] together with his/her university assigned login name (if any). The key can be created on Linux/Unix by:
 
  ssh-keygen


== Write access to repositories ==
By default it is stored at <tt>~/.ssh/id_rsa.pub</tt>.


Write access to Git repositories requires SSH access to this server. It can be activated for your account by an [http://rtime.felk.cvut.cz/~sojka/ administrator]. Login name and password are taken from Novell servers at our department.
=== Creating central repositories ===


It is convenient not to type our password every time you access the repository. You can setup [[Passwordless_SSH|password-less login]] using SSH public/private keys.
To create the repository send an email to the [http://rtime.felk.cvut.cz/~sojka/ administrator] with the name of the repository, a short description and a list of people (SSH public keys) which should have access to the repository.


== Repository Types ==
== Personal repositories ==
This server can host two types of Git repositories.
;Central repositories: These repositories are located under <tt>/var/git</tt> directory and can be [http://rtime.felk.cvut.cz/gitweb browsed online]. This repository can be either created by server administrators or any user can [[#Forking projects hosted on this server|fork an existing repository]]. Central repositories are usually public (read-only accessible to everybody).
;Personal repositories: Any user with shell access can can create his/her own git repository under his/her home directory and make it public using git protocol.


== Creating a personal repository ==
A personal repository can be created this way:


  ssh ''login''@rtime.felk.cvut.cz
  ssh ''login''@rtime.felk.cvut.cz
Line 22: Line 28:
  setfacl -m user:nobody:x $HOME
  setfacl -m user:nobody:x $HOME


== First push ==
== Accessing the repository ==
 
Everybody can use one of following commands to work with the code in the repository (it is not necessary add origin and configure remote branches as described above):
==== Central repository ====
Read-only access for public repositories:
git clone git://rtime.felk.cvut.cz/''repo-name''.git
 
Access managed by gitolite (for users with registered SSH key):
git clone git@rtime.felk.cvut.cz:''repo-name''
 
==== Personal repository ====
Read-only access for public repositories:
git clone git://rtime.felk.cvut.cz/~''yourlogin/''repo-name''.git
 
=== First push ===


After an empty repository is created either by you (personal) of by an admin (central), you can push (upload) data to it:
After an empty repository is created either by you (personal) of by an admin (central), you can push (upload) the data to it:


* Optional: Setup [[Passwordless_SSH|passwordless login to the server]]
* (Optional -- needed only for personal repos): Setup [[Passwordless_SSH|passwordless login to the server]]
* Optional for central repositories: Fill in the description of the project for [http://rtime.felk.cvut.cz/gitweb/ GitWeb interface] &ndash; edit the file <tt>/var/git/''repo-name''.git/description</tt> on the server.
* [[Git#Install_Git|Install Git]] on your local computer
* [[Git#Install_Git|Install Git]] on your local computer
For git 1.6.2 and newer:
* [[#Accessing_the_repository|Clone]] the empty repository.
* Put your sources into your cloned repository
git add .            # tells git to track all files in your project
git commit            # commits the added files to the repository
* Push your sources to the server
git push
For older git versions:
* Put your sources into your local repository
* Put your sources into your local repository
  cd your/project
  cd your/project
Line 35: Line 64:
  git commit            # commits the added files to the repository
  git commit            # commits the added files to the repository
* Then "connect" your repository to the one on this server (replace ''login'' by your login and ''repo-name'' by the name of repository created for you)
* Then "connect" your repository to the one on this server (replace ''login'' by your login and ''repo-name'' by the name of repository created for you)
  git remote add origin ''login''@rtime.felk.cvut.cz:/var/git/''repo-name''.git
  git remote add origin git@rtime.felk.cvut.cz:repo-name # this is for central repos
  git config branch.master.remote origin
  git config branch.master.remote origin
  git config branch.master.merge refs/heads/master
  git config branch.master.merge refs/heads/master
* Push your sources to the server
# Push your sources to the server
  git push --all
  git push --all
== How can other people access your repository ==
Once the repository is not empty, everybody can use one of following commands to work with the code in the repository (it is not necessary add origin and configure remote branches as described above):
==== Central repository ====
git clone ''login''@rtime.felk.cvut.cz:/var/git/''repo-name''.git
git clone git://rtime.felk.cvut.cz/''repo-name''.git
==== Personal repository ====
git clone git://rtime.felk.cvut.cz/~''yourlogin/''repo-name''.git
For other hints refer to the [http://git.or.cz/#documentation git documentation] or to [[Git|this page]].


== Contributing to other projects ==
== Contributing to other projects ==
=== Forking projects hosted on this server ===
If you have an SSH account on this server, you can create a fork of any central git repository even if you do not have write permission to the repository. Fork is clone of other repository which references the cloned repository and disk space is not wasted. To create a fork just run:
fork-git-repo /var/git/<repo-name>.git [ <name-of-fork> ]
If you omit name of fork, your login will be used instead.
Example:
fork-git-repo /var/git/orte.git orte-fixes
Unlike personal repositories, forks can be [http://rtime.felk.cvut.cz/gitweb/orte.git/forks seen in gitweb interface].


=== Using personal repository to contribute to other projects ===
=== Using personal repository to contribute to other projects ===

Revision as of 13:19, 20 October 2010

Repository Types

This server can host two types of Git repositories.

Central repositories
These repositories are managed by Gitolite tool which allows convenient management of developer permissions. Those repositories which are readable by public can be browsed online.
Personal repositories
Any user with shell access to this server can can create his/her own git repository under his/her home directory and make it public using git protocol.

Central Repositories

Write access can only be given to users who sent his/her Open SSH public key to the administrator together with his/her university assigned login name (if any). The key can be created on Linux/Unix by:

 ssh-keygen

By default it is stored at ~/.ssh/id_rsa.pub.

Creating central repositories

To create the repository send an email to the administrator with the name of the repository, a short description and a list of people (SSH public keys) which should have access to the repository.

Personal repositories

A personal repository can be created this way:

ssh login@rtime.felk.cvut.cz
mkdir $HOME/myproject.git
cd $HOME/myproject.git
git init --bare --shared=everybody

If you want to make your repository public, it has to be accessible by user nobody. It is usually sufficient to give "x" permission to your home directory:

setfacl -m user:nobody:x $HOME

Accessing the repository

Everybody can use one of following commands to work with the code in the repository (it is not necessary add origin and configure remote branches as described above):

Central repository

Read-only access for public repositories:

git clone git://rtime.felk.cvut.cz/repo-name.git

Access managed by gitolite (for users with registered SSH key):

git clone git@rtime.felk.cvut.cz:repo-name

Personal repository

Read-only access for public repositories: git clone git://rtime.felk.cvut.cz/~yourlogin/repo-name.git

First push

After an empty repository is created either by you (personal) of by an admin (central), you can push (upload) the data to it:

For git 1.6.2 and newer:

  • Clone the empty repository.
  • Put your sources into your cloned repository
git add .             # tells git to track all files in your project
git commit            # commits the added files to the repository
  • Push your sources to the server
git push

For older git versions:

  • Put your sources into your local repository
cd your/project
git init              # initializes git repository in your project's directory
git add .             # tells git to track all files in your project
git commit            # commits the added files to the repository
  • Then "connect" your repository to the one on this server (replace login by your login and repo-name by the name of repository created for you)
git remote add origin git@rtime.felk.cvut.cz:repo-name  # this is for central repos
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
  1. Push your sources to the server
git push --all

Contributing to other projects

Using personal repository to contribute to other projects

If you do not have write access to the repository of some project (not necessary a central repository on this server), you can work in your personal repository then ask somebody with write access to merge your changes.

  1. Clone a central repository
    git clone git://rtime.felk.cvut.cz/project.git
  2. Add your rtime personal repository as remote (using SSH access)
    git remote add personal yourlogin@rtime.felk.cvut.cz:myproject.git
  3. Edit files in project...
  4. Commit your changes
    git commit ...
  5. Push your changes to your personal repository
    git push personal
  6. Write email to somebody with write access to merge changes in git://rtime.felk.cvut.cz/~yourlogin/myproject.git


Merging changes from forks

git remote add fixes git://rtime.felk.cvut.cz/project/forkname.git
git fetch fixes (or git remote update)
git merge fixes/master