Difference between revisions of "GIT/En"

From TuxFamilyFAQ
Jump to navigationJump to search
(still translating...)
 
(32 intermediate revisions by 13 users not shown)
Line 1: Line 1:
<big>GIT repository</big>
+
<big>Git repository</big>
  
 
{{Template:Languages}}
 
{{Template:Languages}}
Line 6: Line 6:
 
= Description =
 
= Description =
  
[http://git.or.cz git] is an other team coding system such as [[CVS/En|CVS]] or [[SVN/En|SVN]]  
+
[https://git-scm.com/ git] is another team coding system such as [[CVS/En|CVS]] or [[SVN/En|SVN]]
  
= Dependences =
+
If you only want to run git from the command line, then git is all you need to install. <br />
 +
But there are optional Graphical User Interfaces (GUIs) available to help you, such as: <br />
 +
git-gui (git gui) - Helps with staging files for commit, writing commit messages, and pushing. <br />
 +
gitk - Helps with reviewing the history of git commits. <br />
  
*an [[User/En|user account]]
+
= Dependencies =
 +
 
 +
*A [[User/En|user account]]
 
*A [[Group/En|moderated project]]
 
*A [[Group/En|moderated project]]
  
= Creating the GIT repository =
+
= Creating the git repository =
  
*Go on the control panel
+
*Go to the control panel
*Select the project where you want to add a GIT repository
+
*Select the project where you want to add a git repository
 
*Choose the name of your repository
 
*Choose the name of your repository
 
*Validate
 
*Validate
Line 23: Line 28:
  
 
*Don't choose a too usual name
 
*Don't choose a too usual name
*Fill the description field to avoid problems with the moderation team ;)
+
*Fill in the description field to avoid problems with the moderation team ;)
  
 
= Moderation =
 
= Moderation =
Line 32: Line 37:
  
 
On the panel you can choose if you want the repository to be public.
 
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)
+
By accepting it, you allow a read-only anonymous login on the repository and you allow viewing it from the [http://git.tuxfamily.org/ gitweb].
  
 
== Configuration ==
 
== Configuration ==
Line 44: Line 49:
 
*Log into the panel
 
*Log into the panel
 
*click on the group corresponding to your project
 
*click on the group corresponding to your project
*click on your SVN repository
+
*click on your git repository
 
*click on destroy
 
*click on destroy
  
 
= How to use it =
 
= 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.
+
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==
 
== Basic Operations==
Line 59: Line 64:
 
  $ git init
 
  $ git init
 
  $ git add myfirstfile mysecondfile
 
  $ git add myfirstfile mysecondfile
 +
$ git remote add origin ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git
 
  $ git commit -a
 
  $ git commit -a
  $ git push ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git master
+
  $ git push origin master
  
This will create the first commit that will be the 'master' branch of your GIT repository.
+
This will create the first commit that will be the 'master' branch of your git repository. (When your first push is done, you use "git push" normally.)
  
 
(Of course, replace YOURUSER, YOURPROJECT and REPOSITORYNAME by the real values...)
 
(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:  
+
With git 1.6.2+, you can clone an empty repo:
 +
$ git clone ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git
 +
 
 +
It'll complain, but it works.
 +
 
 +
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
 
  $ git clone ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git
Line 77: Line 88:
 
  100% (6/6) done
 
  100% (6/6) done
  
=== Ajout/suppression de fichiers, mise à jour du repository ===
+
=== Adding, removing files, updating your repository ===
  
==== Ajout de fichier ====
+
==== Adding files ====
  
Entrons donc dans notre répertoire
+
Go into your local repository
  $ cd repertoire
+
  $ cd repos
  
Et créons un fichier appelé ##file##
+
let's create a file named 'file'
 
  $ touch file
 
  $ touch file
  
Ensuite, pour l'ajouter au repository, tapez simplement
+
Then to add the file to your repository, just type :
 
  $ git add file
 
  $ git add file
  
Enfin, pour commiter, invoquez la commande suivante :
+
Now, you can commit by typing :
 
  $ git commit file
 
  $ git commit file
  
Une fois vos commits terminés, vous pouvez pusher tout sur le serveur avec la commande:
+
Once the commit is done, you can push everything on the server :
 
  $ git push
 
  $ git push
  
Pour les répertoires, nous aurions procédé de la même façon
+
For directories, we will do the same
 
  $ git add directory/
 
  $ git add directory/
 
  $ git commit directory/
 
  $ git commit directory/
 
  $ git push
 
  $ git push
  
====Suppression de fichier ====
+
====Removing a file ====
Pour supprimer un fichier présent dans le repository, tapez simplement
+
To remove a file, just type :
 
  $ git rm file
 
  $ git rm file
 
  $ git commit
 
  $ git commit
Line 108: Line 119:
  
  
==== Mise à jour du repository ====
+
==== Updating your local copy of the repository ====
Quand on travaille en groupe, il peut être utile de pouvoir mettre à jour son dépot subversion. Pour cela, il suffit d'invoquer la commande suivante à la base du repository
+
When working in a team, it can be useful to update the local copy of your repository :
 
  $ git pull
 
  $ git pull
  '''Attention''': le mot de passe pourra vous sera peut-être demandé plusieurs fois
+
  '''Warning''': You might have to type the password several times
  
== Utilisation de GIT en anonymous (pas encore disponible) ==
+
== Using git as an anonymous user ==
  
Il est possible d'utiliser GIT en anonyme. Cependant, vous n'aurez pas le droit de modifier le repository (suppression ou modification de fichiers). Pour faire un 'checkout' du repository, invoquez la commande suivante :
+
You can use git without logging in. You won't be able to change the repository (add or remove files).
  $ git clone git://git.tuxfamily.org/gitroot/VOTREPROJET/NOMDUREPOSITORY.git
+
To make an anonymous checkout, type this :
 +
  $ git clone git://git.tuxfamily.org/gitroot/YOURPROJECT/YOURREPOSITORY.git
  
Il est également possible de mettre à jour le repository au fur et à mesure que les développeurs mettent à jour le code via un simple
+
Anonymous people can also check for updates by typing :
 
  $ git pull
 
  $ git pull
  
Attention cependant, le mode anonyme n'est disponible que si votre repository est mis en public (réglage par défaut)
+
The anonymous mode is set on the panel (default=allowed)
  
== Utilisation du Gitweb (pas encore disponible) ==
+
== Using CGit ==
  
Vous pouvez consulter les repositories par le web à l'adresse suivante : http://git.tuxfamily.org
+
You can see your all the public repositories here : http://git.tuxfamily.org
Les URLs sont de la forme http://git.tuxfamily.org/git_groupe_dépot/
+
URLs will look like this : http://git.tuxfamily.org/group/repository.git/ ( http://git.tuxfamily.org/tftest/testgit.git/ for example )
  
 +
=== How to keep in touch with your repository ===
  
== Déposer votre clé SSH ==
+
It is possible to monitor branches in your repository using CGit's Atom feed.
  
=== Configurer SSH sous Linux ===
+
  http://git.tuxfamily.org/group/repository.git/atom/?h=master
Vous devez tout d'abord générer votre clef ssh, pour ce faire, ouvrez une console et tapez :
+
 
 +
( http://git.tuxfamily.org/tftest/testgit.git/atom/?h=master for example )
 +
 
 +
Or monitor all branches.
 +
 
 +
  http://git.tuxfamily.org/group/repository.git/atom/?all=1
 +
 
 +
( http://git.tuxfamily.org/tftest/testgit.git/atom/?all=1 for example )
 +
 
 +
== Configuring SSH in GNU/Linux ==
 +
TuxFamily uses Git in conjunction with SSH. This means that every time you access your repository with Git, you will have to type in your TuxFamily password to authenticate. This can become quite annoying and cumbersome.
 +
 
 +
It is possible to use SSH keys in conjunction with software like ssh-agent and keychain to provide a much more comfortable user experience, without sacrificing security.
 +
 
 +
=== Creating and uploading the SSH key ===
 +
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===
+
===Using ssh-agent/keychain===
 +
So far we have not improved the situation very much, since, instead of TuxFamily's password, your key's passphrase will be asked each time you use Git.
  
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.
+
Fortunately there are programs which allow you to manage your SSH keys, so that you will have to type your passphrase just once per session (or, in case of keychain, just once per boot).
*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.
+
====ssh-agent====
 +
The first option is to use ssh-agent.
  
===Utilisation===
+
This uses 2 commands, but first you must kill any existing agents:
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
 
  $killall ssh-agent
  
Puis nous allons lancer les 2 commandes qui vont permettre à votre machine de communiquer avec GIT via SSH.  
+
Now you may run these commands to start a new agent and register the SSH key with the agent.  
 
  $ ssh-agent $SHELL
 
  $ ssh-agent $SHELL
 
  $ ssh-add ~/.ssh/id_rsa
 
  $ 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:
+
To make this happen automatically when you start a shell:
$ 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
 
  if [ -f .ssh-agent ]; then
 
  .ssh-agent
 
  .ssh-agent
Line 175: Line 199:
 
  fi
 
  fi
  
Note : Vous pouvez utiliser KeyChain http://www.gentoo.org/proj/en/keychain pour garder en mémoire votre passphrase et le ssh-agent.
+
====keychain====
 +
Keychain[http://www.gentoo.org/proj/en/keychain] is a SSH key manager that lets you load your SSH keys once per machine boot (i.e., keychain will not exit when you logout, it will sit silently in the background). Keychain uses ssh-agent internally.
 +
 
 +
Using keychain is a two stage process. First you start it, telling it to load your public key into memory:
 +
$ keychain ~/.ssh/id_rsa
 +
 
 +
You will have to type in your key's passphrase. Then you have to read some environmental variables from a file. You can do this with the command
 +
$ source ~/.keychain/`hostname`-sh
 +
 
 +
While you have to start keychain only once per machine boot, you will have to read the environmental variables '''each time''' you start a console session. To avoid this step, you can add something like this at the end of your ".bashrc" file (assuming you are using the bash shell):
 +
 
 +
if <nowiki>[[  $- != *i* ]]</nowiki> ; then
 +
  # Shell is non-interactive.  Be done now!
 +
  return
 +
else
 +
  keychain --nolock ~/.ssh/id_rsa
 +
  source ~/.keychain/`hostname`-sh
 +
fi
 +
 
 +
In case you are wondering, the "if" statement makes sure you are in an interactive shell before launching keychain and reading the environment variables.
 +
 
 +
 
 +
Please refer to the keychain homepage for more documentation.
 +
 
 +
== Pushing to the Git repository on git.tuxfamily.org ==
 +
 
 +
You can access it by ssh but not by the git protocol (git://):
 +
 
 +
$ git push ssh://'USER'@git.tuxfamily.org/gitroot/'PROJECT'/'REPOSITORY'.git master
 +
 
 +
=== git config of the tuxfamily's repository ===
 +
 
 +
The git-config's options receive.denyDeleteCurrent and receive.denyNonFastForwards seem to be set, so you will not be able to delete anything from the branch 'master'.  It is however still possible to delete other branches or tags:
 +
 
 +
$ git push ssh://'USER'@git.tuxfamily.org/gitroot/'PROJECT'/'REPOSITORY'.git "":devel
 +
 
 +
If you want to delete from the master branch once (for example because of a mistake), you can make sure that you have a backup of the repo, then delete it, wait for the deletion to be effective, recreate it and finally push the backup to it (without the unwanted commits of course). If you would like to regularly rebase or delete the branch 'master' you can contact an admin so that it can disable these options on your repository or, better still, implement a configuration of this option through the panel in VHFFS (see https://www.vhffs.org/dev:mainpage).
  
IMPORTANT: Notez bien votre passphrase, elle vous sera demandée lors du login de votre bash.
+
== Collaborative development, Write access ==
 +
All users group will have permission to write to the git. In other words, if you want to develop more on a single repository, it is advisable to add developers to the group through the panel. However, it is necessary that developers create an account on the first panel.
  
==Développement collaboratif, droits d'écriture==
+
A project is a group (within the meaning of the word Unix), add your co-developers to your project so they can commit on changes to the git repository.
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).
+
Otherwise, you may get an error message similar to the following:
  
Autrement, vous risquez d'obtenir le message suivant :
+
error: unable to create temporary sha1 filename ./objects/tmp_obj_9tDId6: Permission denied
  <a remplir en cas d'echec de droits>
+
 +
fatal: failed to write object
 +
  unpack unpacker exited with error code
 +
ng refs/heads/master n/a (unpacker error)
 +
error: failed to push to 'ssh://xxx@git.tuxfamily.org/gitroot/yyy/zzz.git'
  
= Remarques diverses =
+
= Tricks and tips =
*Il est conseillé de ne commiter que des éléments qui compilent correctement (mais qui ne fonctionnent pas forcément) afin que le trunk puisse être testé n'importe quand par de nouveaux utilisateurs.
+
*We recommend committing only code that compiles correctly (even if it doesn't work completely) to always be sure that the repo can be used by new users at any time.
  
*Vous devez choisir les fichiers à versionner, il n'est pas exemple pas nécessaire d'archiver des fichiers de backup (faites attention aux éditeurs qui créent des copies en xxx~, ces copies ne doivent pas être versionnées) ni les fichiers issus directement de la compilation des sources.
+
*You have to choose the files you want to put on your git repository. It is not necessary to upload backup files, or binary files. Be careful, some text editors make automatic backups in xxx~.
  
*Evitez de prendre un nom générique comme "git". Utilisez plutot un nom en rapport avec votre projet ou même, prenez le nom de votre projet ...
+
*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...
  
= Liens utiles =
+
= Useful links =
(a remplir)
+
https://git-scm.com/book/en/v2 Free book: Pro Git, by Scott Chacon and Ben Straub <br />
''Italic text''
+
https://ndpsoftware.com/git-cheatsheet.html Git Cheatsheet <br />

Latest revision as of 23:21, 10 November 2019

Git repository




Description

git is another team coding system such as CVS or SVN

If you only want to run git from the command line, then git is all you need to install.
But there are optional Graphical User Interfaces (GUIs) available to help you, such as:
git-gui (git gui) - Helps with staging files for commit, writing commit messages, and pushing.
gitk - Helps with reviewing the history of git commits.

Dependencies

Creating the git repository

  • Go to 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 in 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 gitweb.

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 git 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 remote add origin ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git
$ git commit -a
$ git push origin master

This will create the first commit that will be the 'master' branch of your git repository. (When your first push is done, you use "git push" normally.)

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

With git 1.6.2+, you can clone an empty repo:

$ git clone ssh://YOURUSER@git.tuxfamily.org/gitroot/YOURPROJECT/REPOSITORYNAME.git

It'll complain, but it works.

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 local copy of the repository

When working in a 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

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 updates by typing :

$ git pull

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

Using CGit

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

How to keep in touch with your repository

It is possible to monitor branches in your repository using CGit's Atom feed.

 http://git.tuxfamily.org/group/repository.git/atom/?h=master

( http://git.tuxfamily.org/tftest/testgit.git/atom/?h=master for example )

Or monitor all branches.

 http://git.tuxfamily.org/group/repository.git/atom/?all=1

( http://git.tuxfamily.org/tftest/testgit.git/atom/?all=1 for example )

Configuring SSH in GNU/Linux

TuxFamily uses Git in conjunction with SSH. This means that every time you access your repository with Git, you will have to type in your TuxFamily password to authenticate. This can become quite annoying and cumbersome.

It is possible to use SSH keys in conjunction with software like ssh-agent and keychain to provide a much more comfortable user experience, without sacrificing security.

Creating and uploading the SSH key

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 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

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.

Using ssh-agent/keychain

So far we have not improved the situation very much, since, instead of TuxFamily's password, your key's passphrase will be asked each time you use Git.

Fortunately there are programs which allow you to manage your SSH keys, so that you will have to type your passphrase just once per session (or, in case of keychain, just once per boot).

ssh-agent

The first option is to use ssh-agent.

This uses 2 commands, but first you must kill any existing agents:

$killall ssh-agent

Now you may run these commands to start a new agent and register the SSH key with the agent.

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

To make this happen automatically when you start a shell:

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

keychain

Keychain[1] is a SSH key manager that lets you load your SSH keys once per machine boot (i.e., keychain will not exit when you logout, it will sit silently in the background). Keychain uses ssh-agent internally.

Using keychain is a two stage process. First you start it, telling it to load your public key into memory:

$ keychain ~/.ssh/id_rsa

You will have to type in your key's passphrase. Then you have to read some environmental variables from a file. You can do this with the command

$ source ~/.keychain/`hostname`-sh

While you have to start keychain only once per machine boot, you will have to read the environmental variables each time you start a console session. To avoid this step, you can add something like this at the end of your ".bashrc" file (assuming you are using the bash shell):

if [[  $- != *i* ]] ; then
  # Shell is non-interactive.  Be done now!
  return
else
  keychain --nolock ~/.ssh/id_rsa
  source ~/.keychain/`hostname`-sh
fi

In case you are wondering, the "if" statement makes sure you are in an interactive shell before launching keychain and reading the environment variables.


Please refer to the keychain homepage for more documentation.

Pushing to the Git repository on git.tuxfamily.org

You can access it by ssh but not by the git protocol (git://):

$ git push ssh://'USER'@git.tuxfamily.org/gitroot/'PROJECT'/'REPOSITORY'.git master

git config of the tuxfamily's repository

The git-config's options receive.denyDeleteCurrent and receive.denyNonFastForwards seem to be set, so you will not be able to delete anything from the branch 'master'. It is however still possible to delete other branches or tags:

$ git push ssh://'USER'@git.tuxfamily.org/gitroot/'PROJECT'/'REPOSITORY'.git "":devel

If you want to delete from the master branch once (for example because of a mistake), you can make sure that you have a backup of the repo, then delete it, wait for the deletion to be effective, recreate it and finally push the backup to it (without the unwanted commits of course). If you would like to regularly rebase or delete the branch 'master' you can contact an admin so that it can disable these options on your repository or, better still, implement a configuration of this option through the panel in VHFFS (see https://www.vhffs.org/dev:mainpage).

Collaborative development, Write access

All users group will have permission to write to the git. In other words, if you want to develop more on a single repository, it is advisable to add developers to the group through the panel. However, it is necessary that developers create an account on the first panel.

A project is a group (within the meaning of the word Unix), add your co-developers to your project so they can commit on changes to the git repository.

Otherwise, you may get an error message similar to the following:

error: unable to create temporary sha1 filename ./objects/tmp_obj_9tDId6: Permission denied

fatal: failed to write object
unpack unpacker exited with error code
ng refs/heads/master n/a (unpacker error)
error: failed to push to 'ssh://xxx@git.tuxfamily.org/gitroot/yyy/zzz.git'

Tricks and tips

  • We recommend committing only code that compiles correctly (even if it doesn't work completely) to always be sure that the repo 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 binary 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

https://git-scm.com/book/en/v2 Free book: Pro Git, by Scott Chacon and Ben Straub
https://ndpsoftware.com/git-cheatsheet.html Git Cheatsheet