tuto:linux:git
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
tuto:linux:git [2017/03/04 18:54] – [rebase] root | tuto:linux:git [2018/09/25 19:15] (Version actuelle) – [Astuces] root | ||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
- | * https://www.atlassian.com/git/ | + | * https://education.github.com/git-cheat-sheet-education.pdf |
* http:// | * http:// | ||
* https:// | * https:// | ||
Ligne 31: | Ligne 31: | ||
==== Astuces ==== | ==== Astuces ==== | ||
+ | * Affiche la liste, taille et attributs des fichiers : | ||
+ | < | ||
+ | $ git ls-tree --full-tree -rl HEAD | ||
+ | </ | ||
+ | |||
* Affiche la racine du projet géré par git : | * Affiche la racine du projet géré par git : | ||
< | < | ||
Ligne 65: | Ligne 70: | ||
* Remplace tous les nom et email d'un auteur par un autre pour l' | * Remplace tous les nom et email d'un auteur par un autre pour l' | ||
< | < | ||
- | $ git filter-branch --commit-filter ' | + | $ git filter-branch --commit-filter ' |
- | if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ]; | + | if [ "$GIT_AUTHOR_NAME" = "root" ]; |
then | then | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
git commit-tree " | git commit-tree " | ||
else | else | ||
git commit-tree " | git commit-tree " | ||
+ | | ||
| | ||
</ | </ | ||
Ligne 84: | Ligne 92: | ||
$ git reflog expire --expire=now --all | $ git reflog expire --expire=now --all | ||
$ git gc --prune=now | $ git gc --prune=now | ||
+ | </ | ||
+ | |||
+ | ==== Configuration ==== | ||
+ | * Désactiver le pager : | ||
+ | < | ||
+ | $ git config --global --replace-all core.pager "less -F -X" | ||
</ | </ | ||
Ligne 385: | Ligne 399: | ||
$ git log --graph --topo-order --decorate --oneline --boundary test..master | $ git log --graph --topo-order --decorate --oneline --boundary test..master | ||
$ git log --graph --full-history --all --color --pretty=format:" | $ git log --graph --full-history --all --color --pretty=format:" | ||
+ | </ | ||
+ | |||
+ | * Rechercher un fichier et ses révisions (même supprimé) : | ||
+ | < | ||
+ | $ git log --all --full-history -- test | ||
</ | </ | ||
* Ajouter un alias pour les logs (celui que j' | * Ajouter un alias pour les logs (celui que j' | ||
< | < | ||
- | $ git config --global alias.lg 'log --graph --full-history --color --oneline --format=" | + | $ git config --global alias.lg 'log --graph --full-history --color --oneline --format=" |
- | $ git config --global alias.lga 'log --graph --full-history --color --oneline --all --format=" | + | $ git config --global alias.lga 'log --graph --full-history --color --oneline --all --format=" |
$ git lg --all | $ git lg --all | ||
$ git lga | $ git lga | ||
Ligne 466: | Ligne 485: | ||
</ | </ | ||
- | * Détruit la branche gigix : | + | * Détruit la branche gigix localement |
< | < | ||
$ git branch -d gigix | $ git branch -d gigix | ||
+ | </ | ||
+ | |||
+ | * Détruit la branche distante gigix sur le remote origin : | ||
+ | < | ||
+ | $ git push -u origin -d gigix | ||
</ | </ | ||
Ligne 594: | Ligne 618: | ||
Les [[#commit]] sont indiqués du plus vieux au plus récent (l’ordre est inversé). | Les [[#commit]] sont indiqués du plus vieux au plus récent (l’ordre est inversé). | ||
</ | </ | ||
+ | |||
+ | * Rejoue les modifications de dev sur le sommet de la branche master : | ||
+ | < | ||
+ | $ git rebase master dev | ||
+ | #ou | ||
+ | $ git rebase -i master dev | ||
+ | #On peut ensuite avancer master au niveau de dev et supprimer dev | ||
+ | $ git checkout master | ||
+ | $ git merge dev --ff-only | ||
+ | $ git branch -d dev | ||
+ | </ | ||
+ | |||
+ | * Récupérer une sous branche d'une branche dans master : | ||
+ | Prenons le cas ci-dessous : | ||
+ | {{ : | ||
+ | |||
+ | Pour fusionner la sous-branche client de server dans master, on fera : | ||
+ | < | ||
+ | $ git rebase --onto master server client | ||
+ | </ | ||
+ | |||
+ | Ce qui donnera : | ||
+ | {{ : | ||
+ | |||
==== merge ==== | ==== merge ==== | ||
- | Fusionne 2 branches | + | Fusionne 2 [[# |
- | * Merge la branche test sur la branche | + | * Merge la [[#branch|branche]] test sur celle courante : |
< | < | ||
$ git merge test | $ git merge test | ||
Ligne 610: | Ligne 658: | ||
< | < | ||
$ git merge test --no-ff | $ git merge test --no-ff | ||
+ | </ | ||
+ | |||
+ | * Merge une branche dans une autre sans modifier l' | ||
+ | < | ||
+ | $ git checkout master | ||
+ | $ git merge --squash gigix | ||
+ | $ git diff --staged | ||
+ | $ git commit -a -m "New feature gigix" | ||
+ | #Si on souhaite supprimer gigix | ||
+ | $ git push origin -d gigix | ||
</ | </ | ||
Ligne 638: | Ligne 696: | ||
< | < | ||
$ git tag | $ git tag | ||
+ | $ git tag -n | ||
+ | $ git tag -l -n | ||
</ | </ | ||
tuto/linux/git.1488653683.txt.gz · Dernière modification : 2017/03/04 18:54 de root