Difference between revisions of "GIT/En"

From TuxFamilyFAQ
Jump to navigationJump to search
(English translation bit.)
Line 131: Line 131:
 
== Déposer votre clé SSH ==
 
== Déposer votre clé SSH ==
  
=== Configurer SSH sous Linux ===
+
=== Configuring SSH in Linux ===
Vous devez tout d'abord générer votre clef ssh, pour ce faire, ouvrez une console et tapez :
+
To use an SSH key, first of all you have to create such key. To create an SSH key open a console an type:
 
  $ ssh-keygen -t rsa
 
  $ ssh-keygen -t rsa
  
Une "passphrase" vous sera demandée. Une fois entrée, votre clef ssh est prète a être utilisée.
+
You will be asked to type a passphrase. Once you have entered your passphrase, the key is ready to be used.
Avant tout, il faut créer un fichier nommé "ssh_keys" qui contiendra le contenu de la clef publique générée.
+
 
Faisons ainsi:  
+
A pair of keys has been generated with the above command: your '''private''' key, which you must keep secret for yourself, and your '''public''' key, which we are going to upload to TuxFamily's server.
 +
 
 +
Your public key is named'''id_rsa.pub''' and it is placed, on creation, in your home directory under the ".ssh" subdirectory. With the following command we will copy your public key into a file called "ssh_keys" in your home directory:
 
  $ cat ~/.ssh/id_rsa.pub >> ~/ssh_keys
 
  $ cat ~/.ssh/id_rsa.pub >> ~/ssh_keys
 +
 +
Next we have to fix the permission on this copy of the public key, which will be uploaded to TuxFamily's server:
 
  $ chmod 700 ~/ssh_keys
 
  $ chmod 700 ~/ssh_keys
  
Il faut maintenant les envoyer sur le serveur distant, en l'occurrence votre FTP Tuxfamily. Ouvrez un client FTP et allez sur votre compte, vous allez voir vos différents projets en cours, c'est à dire vos espaces Web. Restez a la base et copiez le fichier ssh_keys à l'intérieur.
+
Finally, you will have to upload the "ssh_keys" file to TuxFamily's server using FTP. You can use any FTP client. The name of the FTP server is [ftp://ftp.tuxfamily.org/ ftp://ftp.tuxfamily.org/] (you will have to enter your TuxFamily username and password). The "ssh_keys" file must be placed inside the root directory, i.e., the directory you will find yourself in after you connect to the FTP server.
 
 
  
 
===Upload de la clef===
 
===Upload de la clef===

Revision as of 21:26, 12 November 2007

GIT repository




Description

git is an other team coding system such as CVS or SVN

Dependences

Creating the GIT repository

  • Go on the control panel
  • Select the project where you want to add a GIT repository
  • Choose the name of your repository
  • Validate

creating tips

  • Don't choose a too usual name
  • Fill the description field to avoid problems with the moderation team ;)

Moderation

Your repository will be subject to moderation, see here

How to administrate it (panel)

On the panel you can choose if you want the repository to be public. By accepting it, you allow a read-only anonymous login on the repository and you allow viewing it from the sgitweb (coming soon)

Configuration

How to handle group rights

This object can be shared with your group using the ACL

How to destroy it

  • Log into the panel
  • click on the group corresponding to your project
  • click on your SVN repository
  • click on destroy

How to use it

So, you've chosen to be hosted by TuxFamily, that's good. You chose a GIT repository, that's great ! We're going to teach you how to use it.

Basic Operations

Check out

Start by creating a local version of your repository. We will assume that you already have a directory with your project inside.

$ cd myproject
$ git init
$ git add myfirstfile mysecondfile
$ git commit -a
$ git push ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git master

This will create the first commit that will be the 'master' branch of your GIT repository.

(Of course, replace YOURUSER, YOURPROJECT and REPOSITORYNAME by the real values...)

To download a full copy of your GIT repository, you can use the clone command:

$ git clone ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git
remote: Generating pack...
remote: Done counting 6 objects.
remote: Deltifying 6 objects...
remote: (6/6) done
remote: Total 6 (delta 0), reused 0 (delta 0)
Indexing 6 objects...
100% (6/6) done

Adding, removing files, updating your repository

Adding files

Go into your local repository

$ cd repos

let's create a file named 'file'

$ touch file

Then to add the file to your repository, just type :

$ git add file

Now, you can commit by typing :

$ git commit file

Once the commit is done, you can push everything on the server :

$ git push

For directories, we will do the same

$ git add directory/
$ git commit directory/
$ git push

Removing a file

To remove a file, just type :

$ git rm file
$ git commit
$ git push


Updating your repository

When working in team, it can be useful to update the local copy of your repository :

$ git pull
Warning: You might have to type the password several times

Using GIT as an anonymous user (Not available yet)

You can use GIT without logging in. You won't be able to change the repository (add or remove files). To make an anonymous checkout, type this :

$ git clone git://git.tuxfamily.org/gitroot/YOURPROJECT/YOURREPOSITORY.git

Anonymous people can also check for new versions by typing :

$ git pull

The anonymous mode is set on the panel (default=allowed)

Using Gitweb

You can see your all the public repositories here : http://git.tuxfamily.org URLs will look like this : http://git.tuxfamily.org/group/repository/ ( http://git.tuxfamily.org/tftest/testgit/ for example )

Déposer votre clé SSH

Configuring SSH in Linux

To use an SSH key, first of all you have to create such key. To create an SSH key open a console an type:

$ ssh-keygen -t rsa

You will be asked to type a passphrase. Once you have entered your passphrase, the key is ready to be used.

A pair of keys has been generated with the above command: your private key, which you must keep secret for yourself, and your public key, which we are going to upload to TuxFamily's server.

Your public key is namedid_rsa.pub and it is placed, on creation, in your home directory under the ".ssh" subdirectory. With the following command we will copy your public key into a file called "ssh_keys" in your home directory:

$ cat ~/.ssh/id_rsa.pub >> ~/ssh_keys

Next we have to fix the permission on this copy of the public key, which will be uploaded to TuxFamily's server:

$ chmod 700 ~/ssh_keys

Finally, you will have to upload the "ssh_keys" file to TuxFamily's server using FTP. You can use any FTP client. The name of the FTP server is ftp://ftp.tuxfamily.org/ (you will have to enter your TuxFamily username and password). The "ssh_keys" file must be placed inside the root directory, i.e., the directory you will find yourself in after you connect to the FTP server.

Upload de la clef

Il est possible de déposer votre clé SSH (publique) sur les serveurs de Tuxfamily. Cela vous permet de ne pas taper votre mot de passe à chaque opération effectuée sur le serveur Subversion.

  • Pour la déposer, il faut copier le contenu de votre clé publique dans le fichier ssh_keys (le créer si besoin) qui est placé dans votre répertoire de départ (répertoire home). Ce répertoire home est celui sur lequel vous arrivez lorsque vous vous identifiez sur le serveur FTP.
  • Ce fichier doit être placé et avoir un chmod de 700 (faire le chmod 700 à l'aide du client ftp).

Autrement dit, seul VOUS, utilisateur, avez le droit de lire, d'écrire et d'exécuter ce fichier.

Votre clé publique ssh est dans ~/.ssh/id_rsa.pub ou id_dsa.pub (si vous avez retenu un mode faiblard d'encryption), c'est ce fichier que vous mettez en ligne sous le nom ssh_keys.

Utilisation

Désormais il ne reste plus qu'à lancer une session SSH sur votre machine. Ceci se résume en 2 commandes. Tout d'abord (au cas où) il faut "killer" tous les processus ssh-agent si vous en avez lancé un. Sachez qu'il faut toujours verifier que aucun autre agent ssh soit lancé car Gnome et d'autres environnements lancent un agent.

$killall ssh-agent

Puis nous allons lancer les 2 commandes qui vont permettre à votre machine de communiquer avec GIT via SSH.

$ ssh-agent $SHELL
$ ssh-add ~/.ssh/id_rsa

Si tout s'est bien passé, vous n'aurez pas à taper votre mot de passe à chaque commande GIT que vous ferez par la suite. A chaque fois que vous voudrez utiliser cvs, il faudra ouvrir une session SSH:

$ ssh-agent $SHELL
$ ssh-add  ~/.ssh/id_rsa

Et toute les commandes GIT devront être tapées dans le même SHELL.

Pour éviter de devoir ouvrir une session à la main à chaque session, ajoutez ces lignes dans le fichier .bashrc :

if [ -f .ssh-agent ]; then
.ssh-agent
else
killall ssh-agent
ssh-agent > .ssh-agent
ssh-add ~/.ssh/id_rsa
fi

Note : Vous pouvez utiliser KeyChain http://www.gentoo.org/proj/en/keychain pour garder en mémoire votre passphrase et le ssh-agent.

IMPORTANT: Notez bien votre passphrase, elle vous sera demandée lors du login de votre bash.

Développement collaboratif, droits d'écriture

Tous les utilisateurs du groupe auront la permission d'écrire sur le GIT. Autrement dit, si vous désirez développer à plusieurs sur un même repository, il est conseillé d'ajouter les développeurs au groupe via le panel. Toutefois, il faut que les développeurs se créent un compte sur le panel au préalable.

Un projet correspond à un groupe (au sens Unix du terme), il faut ajouter vos co-développeurs à votre projet pour qu'ils puissent commiter des modifications au dépôt subversion (ils auront aussi accès à l'arborescence, permettant de maintenir l'intégralité du projet collaborativement).

Autrement, vous risquez d'obtenir le message suivant :

<a remplir en cas d'echec de droits>

Tricks and tips

  • We recomand committing only code that compile correctly (even if it doesn't work completely ) to always be sure that the trunk can be used by new users at any time.
  • You have to choose the files you want to put on your GIT repository. It is not necessary to upload backup files, or binaries files. Be careful, some text editors make automatic backups in xxx~.
  • Please don't choose a generic name for your repository such as "git". Instead, choose an intelligent name or in the worse case, use your project name...

Useful links