fixing small errors

This commit is contained in:
Yann Esposito (Yogsototh) 2013-02-26 12:21:15 +01:00
parent 4f6185f294
commit 5334c8a3e2
3 changed files with 768 additions and 768 deletions

View file

@ -25,13 +25,13 @@ Here is the list of sufficient and necessary command to use [Git][git]. There is
Get a project from the web:
~~~~~~ {.zsh}
<code class="zsh">
git clone ssh://server/path/to/project
~~~~~~
</code>
Everyday [Git][git] usage:
~~~~~~ {.zsh}
<code class="zsh">
# get modifications from other
git pull
# read what was done
@ -53,7 +53,7 @@ git commit -a -m "Fix bug #321"
# send local modifications to other
git push
~~~~~~
</code>
This article is written for people knowing very few about versionning systems. It is also written for those who had didn't followed progress since CVS or subversion (SVN). This is why, in a first time I'll explain quickly which are the goal of such systems. Secondly, I'll explain how to install and configure [Git][git]. Then, I give the command for each feature a <abbr title="Decentralized Concurent Versions System">DCVS</abbr> must have.
@ -76,15 +76,15 @@ When somebody work with files without a versions system, the following happens f
When you modify a somehow critical file you don't want to loose. You copy naturally this file with another name. For example:
~~~~~~ {.zsh}
<code class="zsh">
$ cp fichier_important.c fichier_important.c.bak
~~~~~~
</code>
In consequence of what, the new file, play the role of *backup*. If you break everything, you can always return in the last state by overwriting your modifications.
Of course, this method is not very professional and is a bit limited. If you make many modifications, you'll end with many files with strange names like:
<div>
~~~~~~ {.zsh}
<code class="zsh">
fichier_important.c.bak
fichier_important.c.old
fichier_important.c.Bakcup
@ -92,7 +92,7 @@ fichier_important.c.BAK.2009-11-14
fichier_important.c.2009.11.14
fichier_important.c.12112009
old.fichier_important.c
~~~~~~
</code>
</div>
If you want to make it works correctly, you'll have to use naming convention. Files take many place even if you modify most of time only some lines.
@ -123,11 +123,11 @@ Version Systems are already useful to manage its own projects. They help to orga
Let's begin by an example, a two person project ; Alex and Beatrice. On a file containing a *Lovecraft*'s gods list:
<div style="width: 10em; margin-left: auto; margin-right: auto">
~~~~~~ {.zsh}
<code class="zsh">
Cthulhu
Shubniggurath
Yogsototh
~~~~~~
</code>
</div>
Say Alex is home and modify the file:
@ -246,26 +246,26 @@ Now let's see how to obtain all these things easily with [Git][git].
Under Linux Ubuntu or Debian:
~~~~~~ {.zsh}
<code class="zsh">
$ sudo apt-get install git
~~~~~~
</code>
Under Mac OS X:
* install [MacPorts](http://macports.org/install.php)
* install [Git][git]
~~~~~~ {.zsh}
<code class="zsh">
$ sudo port selfupdate
$ sudo port install git-core
~~~~~~
</code>
## Global configuration
Save the following file as your `~/.gitconfig`.
~~~~~~
<code class="zsh">
[color]
branch = auto
diff = auto
@ -285,15 +285,15 @@ Save the following file as your `~/.gitconfig`.
# conflict = !gitx --left-right HEAD...MERGE_HEAD
[branch]
autosetupmerge = true
~~~~~~
</code>
You can achieve the same result using for each entry the command: `git config --global`. Next, configure your name and your email. For example, if your name is John Doe and your email is `john.doe@email.com`. Launch the following commands:
~~~~~~ {.zsh}
<code class="zsh">
$ git config --global user.name John Doe
$ git config --global user.email john.doe@email.com
~~~~~~
</code>
Here it is. Base configuration is over. The file containing alias will help to type shorter commands.
@ -301,35 +301,35 @@ Here it is. Base configuration is over. The file containing alias will help to t
If a project is already versionned with [Git][git] you should have an `URL` of the sources. Then use the following command:
~~~~~~ {.zsh}
<code class="zsh">
$ cd ~/Projets
$ git clone git://main.server/path/to/file
~~~~~~
</code>
If there is no git server but you've got an `ssh` access. Just replace the `git://host` by `ssh://user@host`. In order not to type your password each time, use:
~~~~~~ {.zsh}
<code class="zsh">
$ ssh-keygen -t rsa
~~~~~~
</code>
Reply to question and **do not enter** a password. Then copy your keys to the distant server. This is not the safest way to do this. The safest being, using `ssh-agent`.
The easiest way if you have `ssh-copy-id`:
~~~~~~ {.zsh}
<code class="zsh">
me@locahost$ ssh-copy-id ~/.ssh/id_rsa.pub me@main.server
~~~~~~
</code>
or manually
~~~~~~ {.zsh}
<code class="zsh">
me@locahost$ scp ~/.ssh/id_rsa.pub me@main.server:
me@locahost$ ssh me@main.server
password:
me@main.server$ cat id_rsa.pub >> ~/.ssh/authorized_keys
me@main.server$ rm id_rsa.pub
me@main.server$ logout
~~~~~~
</code>
Now you don't need to write your password to access the `main.server`.
@ -337,34 +337,34 @@ Now you don't need to write your password to access the `main.server`.
Suppose you already have a project with files. Then it is really easy to version it.
~~~~~~ {.zsh}
<code class="zsh">
$ cd /path/to/project
$ git init
$ git add .
$ git commit -m "Initial commit"
~~~~~~
</code>
Let do a small remark. If you don't want to *version* every file. Typically intermediate compilation file, swap files... Then you need to exclude them. Just before launching the `git add .` command. You need to create a `.gitignore` file in the root directory of your project. This file will contain all exclude *pattern*. For example:
~~~~~~ {.zsh}
<code class="zsh">
*.o
*.bak
*.swp
*~
~~~~~~
</code>
Now, if you want to create a repository on a distant server, it *must* not be in `bare` mode. The repository will contain only versionning informations, but not the files of the project. To achieve that:
~~~~~~ {.zsh}
<code class="zsh">
$ cd /path/to/local/project
$ git clone --bare . ssh://server/path/to/project
~~~~~~
</code>
Others will be able to get your modifications.
~~~~~~ {.zsh}
<code class="zsh">
git clone ssh://server/path/to/project
~~~~~~
</code>
## Abstract of the second step
@ -402,9 +402,9 @@ Conflicts can arise when you change the same line of code on the same file from
You start from the following file
<div style="width: 18em; margin-left: auto; margin-right: auto">
~~~~~~ {.zsh}
<code class="zsh">
Zoot
~~~~~~
</code>
</div>
and you modify one line
@ -426,7 +426,7 @@ Zoot<span class="StringConstant"><strong>, just Zoot</strong></span>
Now when you do a:
<div>
~~~~~~ {.zsh}
<code class="zsh">
$ git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
@ -436,7 +436,7 @@ From /home/yogsototh/tmp/conflictTest
Auto-merging foo
CONFLICT (content): Merge conflict in foo
Automatic merge failed; fix conflicts and then commit the result.
~~~~~~
</code>
</div>
Our file `foo` now contains:
@ -464,9 +464,9 @@ Zoot <span class="Constant"><strong>the not so pure</strong></span>
and to commit
<div>
~~~~~~ {.zsh}
<code class="zsh">
git commit -a -m "conflict resolved"
~~~~~~
</code>
</div>
Now you're ready to use [Git][git].
@ -510,113 +510,113 @@ In the first part, we saw the list of resolved problem by [Git][git]. To resume
### get others modifications
~~~~~~ {.zsh}
<code class="zsh">
$ git pull
~~~~~~
</code>
### send modifications to others
~~~~~~ {.zsh}
<code class="zsh">
$ git push
~~~~~~
</code>
or more generally
~~~~~~ {.zsh}
<code class="zsh">
$ git pull
$ git push
~~~~~~
</code>
### get back in time
#### For all tree
~~~~~~ {.zsh}
<code class="zsh">
$ git checkout
~~~~~~
</code>
~~~~~~ {.zsh}
<code class="zsh">
$ git revert
~~~~~~
</code>
revert three version before (see my `.gitconfig` file).
~~~~~~ {.zsh}
<code class="zsh">
$ git uncommit 3
~~~~~~
</code>
Undo the las merge (if something goes wrong)
~~~~~~ {.zsh}
<code class="zsh">
$ git revertbeforemerge
~~~~~~
</code>
#### For one file
~~~~~~ {.zsh}
<code class="zsh">
$ git checkout file
$ git checkout VersionHash file
$ git checkout HEAD~3 file
~~~~~~
</code>
### list differences between each version
list files being modified
~~~~~~ {.zsh}
<code class="zsh">
$ git status
~~~~~~
</code>
differences between last version files and local files
~~~~~~ {.zsh}
<code class="zsh">
$ git diff
~~~~~~
</code>
differences between some version and local files
~~~~~~ {.zsh}
<code class="zsh">
$ git diff VersionHash fichier
~~~~~~
</code>
### name some version to refer to them in the future
~~~~~~ {.zsh}
<code class="zsh">
$ git tag 'toto'
~~~~~~
</code>
### show historic of modifications
~~~~~~ {.zsh}
<code class="zsh">
$ git log
$ git lg
$ git logfull
~~~~~~
</code>
### know who did what and when
~~~~~~ {.zsh}
<code class="zsh">
$ git blame fichier
~~~~~~
</code>
### handle conflicts
~~~~~~ {.zsh}
<code class="zsh">
$ git conflict
~~~~~~
</code>
### manage branches
To create a branch:
~~~~~~ {.zsh}
<code class="zsh">
$ git branch branch_name
~~~~~~
</code>
To change the current branch:
~~~~~~ {.zsh}
<code class="zsh">
$ git checkout branch_name
~~~~~~
</code>
[git]: http://git-scm.org "Git"

View file

@ -25,13 +25,13 @@ Voici la liste des commandes nécessaires et suffisantes pour utiliser [Git][git
Récupérer un projet :
~~~~~~ {.zsh}
<code class="zsh">
git clone ssh://server/path/to/project
~~~~~~
</code>
Utiliser [Git][git] tous les jours :
~~~~~~ {.zsh}
<code class="zsh">
# get modifications from other
git pull
# read what was done
@ -53,7 +53,7 @@ git commit -a -m "Fix bug #321"
# send local modifications to other
git push
~~~~~~
</code>
Cet article est écrit pour ceux qui en savent très peu sur les systèmes de version. Il est aussi écrit pour ceux qui n'ont pas suivi les progrès accomplis depuis CVS ou subversion (SVN). Cest pourquoi, dans un premier temps, jexplique rapidement quels sont les buts poursuivis par les systèmes de versions. J'explique ensuite comment installer et configurer [Git][git]. Puis, pour chaque action que doivent accomplir les <abbr title="Decentralized Concurent Versions System">DCVS</abbr> je donne les commandes [Git][git] qui y correspondent.
@ -76,13 +76,13 @@ Quand on travaille avec des fichiers sans système de version voilà ce qui arri
Lorsqu'on modifie un fichier un peu critique et qu'on a pas envie de perdre, on se retrouve souvent à le recopier sous un autre nom. Par exemple
~~~~~~ {.zsh}
<code class="zsh">
$ cp fichier_important.c fichier_important.c.bak
~~~~~~
</code>
Du coups, ce nouveau fichier joue le rôle de *backup*. Si on casse tout, on peut toujours écraser les modifications que nous avons faites. Évidemment le problème avec cette façon de faire c'est que ce n'est pas très professionnel. Et puis c'est un peu limité. Si on veut faire trois ou quatre modifications on se retrouve avec plein de fichiers. Parfois avec des nom bizarres comme :
~~~~~~ {.zsh}
<code class="zsh">
fichier_important.c.bak
fichier_important.c.old
fichier_important.c.Bakcup
@ -90,7 +90,7 @@ fichier_important.c.BAK.2009-11-14
fichier_important.c.2009.11.14
fichier_important.c.12112009
old.fichier_important.c
~~~~~~
</code>
Bon alors si on veut que ça marche il faut se fixer des conventions de nommage. Les fichiers prennent beaucoup de place alors que souvent il n'y a que quelques lignes différentes entre le fichier et son backup...
@ -120,11 +120,11 @@ Les systèmes de versions sont déjà intéressants pour gérer ses projets pers
Commençons par un exemple avec un projet fait par deux personnes ; Alex et Béatrice.
Sur un fichier contenant une liste de dieux *Lovecraftiens* :
~~~~~~ {.zsh}
<code class="zsh">
Cthulhu
Shubniggurath
Yogsototh
~~~~~~
</code>
Disons que Alex est chez lui, il modifie le fichier :
@ -244,26 +244,26 @@ Maintenant voyons comment obtenir toutes ces choses facilement avec [Git][git].
Sous Linux Ubuntu ou Debian :
~~~~~~ {.zsh}
<code class="zsh">
$ sudo apt-get install git
~~~~~~
</code>
Sous Mac OS X :
* installez [MacPorts](http://macports.org/install.php)
* installez [Git][git]
~~~~~~ {.zsh}
<code class="zsh">
$ sudo port selfupdate
$ sudo port install git-core
~~~~~~
</code>
## Configuration globale
Enregistrez le fichier suivant comme le fichier `~/.gitconfig`.
~~~~~~
<code class="zsh">
[color]
branch = auto
diff = auto
@ -283,16 +283,16 @@ Enregistrez le fichier suivant comme le fichier `~/.gitconfig`.
# conflict = !gitx --left-right HEAD...MERGE_HEAD
[branch]
autosetupmerge = true
~~~~~~
</code>
Vous pouvez obtenir le même résultat en utilisant pour chaque entrée la commande `git config --global`.
Configurez ensuite votre nom et votre email. Par exemple si vous vous appelez John Doe et que votre email est `john.doe@email.com`. Lancez les commandes suivantes :
~~~~~~ {.zsh}
<code class="zsh">
$ git config --global user.name John Doe
$ git config --global user.email john.doe@email.com
~~~~~~
</code>
Voilà, la configuration de base est terminée. J'ai créé dans le fichier de configuration global des *alias* qui vont permettre de taper des commandes un peu plus courtes.
@ -300,35 +300,35 @@ Voilà, la configuration de base est terminée. J'ai créé dans le fichier de c
Si un projet est déjà versionné avec [Git][git] vous devez avoir une `URL` pointant vers les sources du projet. La commande a exécuter est alors très simple.
~~~~~~ {.zsh}
<code class="zsh">
$ cd ~/Projets
$ git clone git://main.server/path/to/file
~~~~~~
</code>
S'il n'y a pas de serveur git sur le serveur distant, mais que vous avez un accès `ssh`, il suffit de remplacer le `git` de l'url par `ssh`. Pour ne pas avoir à entrer votre mot de passe à chaque fois le plus simple est de procéder comme suit :
~~~~~~ {.zsh}
<code class="zsh">
$ ssh-keygen -t rsa
~~~~~~
</code>
Répondez aux question et n'entrez **surtout PAS** de mot de passe. Ensuite copiez les clés sur le serveur distant. Ce n'est pas la façon la plus sûre de procéder. L'idéal étant d'écrire quand même un mot de passe et d'utiliser `ssh-agent`.
Ensuite le plus simple, si vous possédez `ssh-copy-id` (sous Ubuntu par exemple) :
~~~~~~ {.zsh}
<code class="zsh">
me@locahost$ ssh-copy-id -i ~/.ssh/id_rsa.pub me@main.server
~~~~~~
</code>
ou manuellement :
~~~~~~ {.zsh}
<code class="zsh">
me@locahost$ scp ~/.ssh/id_rsa.pub me@main.server:
me@locahost$ ssh me@main.server
password:
me@main.server$ cat id_rsa.pub >> ~/.ssh/authorized_keys
me@main.server$ rm id_rsa.pub
me@main.server$ logout
~~~~~~
</code>
Maintenant vous n'avez plus besoin de taper votre mot de passe pour accéder à `main.server`. Et donc aussi pour les commandes `git`.
@ -336,34 +336,34 @@ Maintenant vous n'avez plus besoin de taper votre mot de passe pour accéder à
Supposons que vous avez déjà un projet avec des fichiers. Alors il est très facile de le versionner.
~~~~~~ {.zsh}
<code class="zsh">
$ cd /path/to/project
$ git init
$ git add .
$ git commit -m "Initial commit"
~~~~~~
</code>
Une petite précision. Si vous ne souhaitez pas *versionner* tous les fichiers. Par exemple, les fichiers de compilations intermédiaires. Alors il faut les exclure. Pour cela, avant de lancer la commande `git add .`. Il faut créer un fichier `.gitignore` qui va contenir les *pattern* que git doit ignorer. Par exemple :
~~~~~~ {.zsh}
<code class="zsh">
*.o
*.bak
*.swp
*~
~~~~~~
</code>
Maintenant si vous voulez créer un repository sur un serveur distant, il faut absolument qu'il soit en mode `bare`. C'est-à-dire que le repository ne contiendra que la partie contenant les informations utile à la gestion de git, mais pas les fichiers du projet. Sans rentrer dans les détails, il suffit de lancer :
~~~~~~ {.zsh}
<code class="zsh">
$ cd /path/to/local/project
$ git clone --bare . ssh://server/path/to/project
~~~~~~
</code>
Les autres pourront alors récupérer les modifications via la commande vue précédemment :
~~~~~~ {.zsh}
<code class="zsh">
git clone ssh://server/path/to/project
~~~~~~
</code>
## Résumé de la seconde étape
@ -401,9 +401,9 @@ Les conflits peuvent survenir lorsque vous modifiez les même lignes de codes su
Vous partez du fichier suivant :
<div style="width: 18em; margin-left: auto; margin-right: auto">
~~~~~~ {.zsh}
<code class="zsh">
Zoot
~~~~~~
</code>
</div>
et vous modifiez une ligne
@ -425,7 +425,7 @@ Zoot<span class="StringConstant"><strong>, just Zoot</strong></span>
Maintenant quand vous lancez la commande
<div>
~~~~~~ {.zsh}
<code class="zsh">
$ git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
@ -435,7 +435,7 @@ From /home/yogsototh/tmp/conflictTest
Auto-merging foo
CONFLICT (content): Merge conflict in foo
Automatic merge failed; fix conflicts and then commit the result.
~~~~~~
</code>
</div>
Notre fichier `foo` contient alors :
@ -463,9 +463,9 @@ Zoot <span class="Constant"><strong>the not so pure</strong></span>
et de 'commiter' tout simplement :
<div>
~~~~~~ {.zsh}
<code class="zsh">
git commit -a -m "conflict resolved"
~~~~~~
</code>
</div>
Maintenant vous êtes fin prêt pour utiliser [Git][git].
@ -509,113 +509,113 @@ Dans la première partie, nous avons vu la liste des problèmes résolus par [Gi
### récupérer les modifications des autres
~~~~~~ {.zsh}
<code class="zsh">
$ git pull
~~~~~~
</code>
### envoyer ses modifications aux autres
~~~~~~ {.zsh}
<code class="zsh">
$ git push
~~~~~~
</code>
ou plus généralement
~~~~~~ {.zsh}
<code class="zsh">
$ git pull
$ git push
~~~~~~
</code>
### revenir dans le temps
#### Pour toute l'arborescence
~~~~~~ {.zsh}
<code class="zsh">
$ git checkout
~~~~~~
</code>
~~~~~~ {.zsh}
<code class="zsh">
$ git revert
~~~~~~
</code>
revenir trois versions en arrière
~~~~~~ {.zsh}
<code class="zsh">
$ git uncommit 3
~~~~~~
</code>
Revenir avant le dernier merge (s'il s'est mal passé).
~~~~~~ {.zsh}
<code class="zsh">
$ git revertbeforemerge
~~~~~~
</code>
#### Pour un seul fichier
~~~~~~ {.zsh}
<code class="zsh">
$ git checkout file
$ git checkout VersionHash file
$ git checkout HEAD~3 file
~~~~~~
</code>
### lister les différences entre chaque version
liste les fichiers en cours de modifications
~~~~~~ {.zsh}
<code class="zsh">
$ git status
~~~~~~
</code>
différences entre les fichiers de la dernière version et les fichiers locaux.
~~~~~~ {.zsh}
<code class="zsh">
$ git diff
~~~~~~
</code>
liste les différences entre les fichier d'une certaine version et les fichiers locaux.
~~~~~~ {.zsh}
<code class="zsh">
$ git diff VersionHash fichier
~~~~~~
</code>
### nommer certaines versions pour s'y référer facilement
~~~~~~ {.zsh}
<code class="zsh">
$ git tag 'toto'
~~~~~~
</code>
### afficher l'historique des modifications
~~~~~~ {.zsh}
<code class="zsh">
$ git log
$ git lg
$ git logfull
~~~~~~
</code>
### savoir qui a fait quoi et quand
~~~~~~ {.zsh}
<code class="zsh">
$ git blame fichier
~~~~~~
</code>
### gérer des conflits
~~~~~~ {.zsh}
<code class="zsh">
$ git conflict
~~~~~~
</code>
### manipuler facilement des branches
Pour créer une branche :
~~~~~~ {.zsh}
<code class="zsh">
$ git branch branch_name
~~~~~~
</code>
Pour changer de branche courante :
~~~~~~ {.zsh}
<code class="zsh">
$ git checkout branch_name
~~~~~~
</code>
[git]: http://git-scm.org "Git"

File diff suppressed because it is too large Load diff