trailing whitespaces
This commit is contained in:
parent
98f4a84cba
commit
0071e5f496
62
HowtoGit.md
62
HowtoGit.md
|
@ -39,7 +39,7 @@ $ cd foo
|
|||
$ git init
|
||||
~~~
|
||||
|
||||
### Cloner un dépôt
|
||||
### Cloner un dépôt
|
||||
|
||||
Plusieurs méthodes d'accès pour récupérer un dépôt : SSH, HTTP(S), Git, file.
|
||||
|
||||
|
@ -66,7 +66,7 @@ Modification d'un fichier existant :
|
|||
$ vi main.c
|
||||
$ git add main.c
|
||||
$ git commit -v
|
||||
~~~
|
||||
~~~
|
||||
|
||||
*Note* : on peut éviter de faire `git add` et faire uniquement `git commit -a` si l'on est sûr qu'aucun autre fichier n'a été modifié (mais c'est une mauvaise habitude que l'on déconseille).
|
||||
|
||||
|
@ -135,10 +135,10 @@ $ git merge --no-ff myfeature
|
|||
Pousser une branche locale vers le dépôt référencé comme distant :
|
||||
|
||||
~~~{.bash}
|
||||
$ git push origin myfeature
|
||||
$ git push origin myfeature
|
||||
~~~
|
||||
|
||||
Supprimer une branche locale et distante :
|
||||
Supprimer une branche locale et distante :
|
||||
|
||||
~~~{.bash}
|
||||
$ git branch -d myfeature
|
||||
|
@ -147,7 +147,7 @@ $ git push origin :myfeature
|
|||
|
||||
|
||||
## Commandes avancées
|
||||
|
||||
|
||||
### Afficher l'historique
|
||||
|
||||
Affichage de l'historique de différentes façons :
|
||||
|
@ -217,7 +217,7 @@ Modifier son dernier commit :
|
|||
$ vi main.c
|
||||
$ git add main.c
|
||||
$ git commit --amend
|
||||
~~~
|
||||
~~~
|
||||
|
||||
Modifier son avant-dernier commit :
|
||||
|
||||
|
@ -234,14 +234,14 @@ $ git rebase --continue
|
|||
|
||||
### Picorer un commit d'une autre branche (cherry-pick)
|
||||
|
||||
~~~{.bash}
|
||||
~~~{.bash}
|
||||
$ git cherry-pick <SHA1 du commit>
|
||||
~~~
|
||||
~~~
|
||||
|
||||
### gitignore
|
||||
|
||||
Créer un fichier `.gitignore` à la racine pour ignorer certains fichiers/chemins :
|
||||
|
||||
|
||||
~~~
|
||||
$ cat .gitignore
|
||||
|
||||
|
@ -437,17 +437,17 @@ $ git remote
|
|||
### Echanger des commits sous forme de patchs Git
|
||||
|
||||
Pour transmettre ses 3 derniers commits, on peut générer 3 patches qui contiendront les diffs ainsi que les messages de commit :
|
||||
|
||||
|
||||
~~~{.bash}
|
||||
$ git format-patch -3
|
||||
~~~
|
||||
|
||||
Si l'on a ces 3 patches, on peut les appliquer sur son dépôt local ainsi :
|
||||
|
||||
|
||||
~~~{.bash}
|
||||
$ git am 000*.patch
|
||||
~~~
|
||||
|
||||
|
||||
### hooks
|
||||
|
||||
On peut gérer des hooks à différents moments (pre-commit, post-commit, pre-push, post-push, etc.),
|
||||
|
@ -510,33 +510,33 @@ Cet historique est notamment accessible avec la commande `git reflog`.
|
|||
|
||||
Avec un dépôt *foo* existant, on autorisera les utilisateurs que si ils appartiennent au groupe *git* :
|
||||
|
||||
~~~
|
||||
~~~
|
||||
# cd foo
|
||||
# git config core.sharedRepository group
|
||||
# addgroup git
|
||||
# chgrp -R git .
|
||||
# chmod g=rwXs,o= -R .
|
||||
# chmod g=rwX -R . # astuce pour garder le +s sur les répertoires
|
||||
~~~
|
||||
~~~
|
||||
|
||||
### Importer un dépôt SVN dans GIT
|
||||
|
||||
Ce script permet de récupérer la liste des auteurs SVN, modifiez la comme voulu.
|
||||
|
||||
~~~{.bash}
|
||||
~~~{.bash}
|
||||
#!/usr/bin/env bash
|
||||
authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)
|
||||
for author in ${authors}; do
|
||||
echo "${author} = Prenom Nom <jdoe@example.com>";
|
||||
done
|
||||
~~~
|
||||
~~~
|
||||
|
||||
On lance ensuite la commande suivante :
|
||||
|
||||
|
||||
~~~{.bash}
|
||||
$ git svn --authors-file=path/to/authors_file clone svn+ssh://svn.example.com/path/to/repo
|
||||
~~~
|
||||
|
||||
|
||||
### Importer un dépôt CVS dans GIT
|
||||
|
||||
Lancer la commande suivante :
|
||||
|
@ -556,7 +556,7 @@ $ git-archimport -v foo@arch.example.com--branch
|
|||
### Convertir un dépôt en utf8
|
||||
|
||||
Créer un fichier exécutable dans `/tmp/recode-all-files` :
|
||||
|
||||
|
||||
~~~{.bash}
|
||||
#!/bin/sh
|
||||
find . -type f -print | while read f; do
|
||||
|
@ -583,7 +583,7 @@ $ git filter-branch --msg-filter 'iconv -f iso-8859-1 -t utf-8' -- --all
|
|||
Ceci est évidemment déconseillé, car cela mettra aussi à jour les fichiers, ce qui nécessite
|
||||
de faire un `git reset --hard`. Mais si l'on veut tout de même le forcer :
|
||||
|
||||
~~~
|
||||
~~~
|
||||
$ git push
|
||||
Counting objects: 7, done.
|
||||
Delta compression using up to 4 threads.
|
||||
|
@ -596,24 +596,24 @@ remote: error: By default, updating the current branch in a non-bare repository
|
|||
remote: error: is denied, because it will make the index and work tree inconsistent
|
||||
remote: error: with what you pushed, and will require 'git reset --hard' to match
|
||||
remote: error: the work tree to HEAD.
|
||||
remote: error:
|
||||
remote: error:
|
||||
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
|
||||
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
|
||||
remote: error: its current branch; however, this is not recommended unless you
|
||||
remote: error: arranged to update its work tree to match what you pushed in some
|
||||
remote: error: other way.
|
||||
remote: error:
|
||||
remote: error:
|
||||
remote: error: To squelch this message and still keep the default behaviour, set
|
||||
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
|
||||
! [remote rejected] master -> master (branch is currently checked out)
|
||||
~~~
|
||||
~~~
|
||||
|
||||
Il faut ajouter dans la config du repository "distant" :
|
||||
|
||||
~~~
|
||||
~~~
|
||||
[receive]
|
||||
denyCurrentBranch = warn
|
||||
~~~
|
||||
~~~
|
||||
|
||||
### Transformer un non-bare repository en bare repository
|
||||
|
||||
|
@ -624,10 +624,10 @@ $ rm -rf *
|
|||
~~~
|
||||
|
||||
Puis d'indiquer dans la config du repository :
|
||||
|
||||
|
||||
~~~
|
||||
bare = true
|
||||
~~~
|
||||
~~~
|
||||
|
||||
### Mettre en place des notifications de push
|
||||
|
||||
|
@ -641,16 +641,16 @@ $ git hooks.mailinglist git@example.com
|
|||
~~~
|
||||
|
||||
Pour recevoir les patches :
|
||||
|
||||
|
||||
~~~{.bash}
|
||||
$ git config hooks.showrev "git show -C %s; echo
|
||||
~~~
|
||||
~~~
|
||||
|
||||
### Ignorer les vérifications SSL
|
||||
|
||||
~~~{.basb}
|
||||
~~~{.basb}
|
||||
$ git config --global http.sslverify "false"
|
||||
~~~
|
||||
~~~
|
||||
|
||||
### Nettoyage d'un dépôt Git
|
||||
|
||||
|
|
Loading…
Reference in a new issue