Outils pour utilisateurs

Outils du site


tuto:linux:git

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tuto:linux:git [2017/09/17 17:44] – [log] roottuto:linux:git [2018/09/25 19:15] (Version actuelle) – [Astuces] root
Ligne 3: Ligne 3:
   * https://git-scm.com/book/fr/v2   * https://git-scm.com/book/fr/v2
   * https://www.grafikart.fr/formations/git   * https://www.grafikart.fr/formations/git
-  * https://www.atlassian.com/git/tutorials/what-is-version-control+  * https://education.github.com/git-cheat-sheet-education.pdf
   * http://cdiese.fr/git-en-5-min/   * http://cdiese.fr/git-en-5-min/
   * https://delicious-insights.com/fr/articles/bien-utiliser-git-merge-et-rebase/   * https://delicious-insights.com/fr/articles/bien-utiliser-git-merge-et-rebase/
Ligne 31: Ligne 31:
  
 ==== Astuces ==== ==== Astuces ====
 +  * Affiche la liste, taille et attributs des fichiers :
 +<xtermrtf>
 +$ git ls-tree --full-tree -rl HEAD
 +</xtermrtf>
 +
   * Affiche la racine du projet géré par git :   * Affiche la racine du projet géré par git :
 <xtermrtf> <xtermrtf>
Ligne 65: Ligne 70:
   * Remplace tous les nom et email d'un auteur par un autre pour l'ensemble des [[#commit]] :   * Remplace tous les nom et email d'un auteur par un autre pour l'ensemble des [[#commit]] :
 <xtermrtf> <xtermrtf>
-$ git filter-branch --commit-filter ' +$ git filter-branch --commit-filter '                                                                                       
-         if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ];+         if [ "$GIT_AUTHOR_NAME" = "root" ];
          then          then
-                 GIT_AUTHOR_NAME="Scott Chacon"; +                 GIT_AUTHOR_NAME="Ghislain LE MEUR"; 
-                 GIT_AUTHOR_EMAIL="schacon@example.com";+                 GIT_COMMITTER_NAME="Ghislain LE MEUR"; 
 +                 GIT_AUTHOR_EMAIL="gigi206@users.noreply.github.com"; 
 +                 GIT_COMMITTER_EMAIL="gigi206@users.noreply.github.com"; 
                  git commit-tree "$@";                  git commit-tree "$@";
          else          else
                  git commit-tree "$@";                  git commit-tree "$@";
 +         fi' -f HEADt commit-tree "$@";
          fi' HEAD          fi' HEAD
 </xtermrtf> </xtermrtf>
Ligne 84: Ligne 92:
 $ git reflog expire --expire=now --all $ git reflog expire --expire=now --all
 $ git gc --prune=now $ git gc --prune=now
 +</xtermrtf>
 +
 +==== Configuration ====
 +  * Désactiver le pager :
 +<xtermrtf>
 +$ git config --global --replace-all core.pager "less -F -X"
 </xtermrtf> </xtermrtf>
  
Ligne 387: Ligne 401:
 </xtermrtf> </xtermrtf>
  
-  * Rechercher un fichier et se revisions (même supprimé) :+  * Rechercher un fichier et ses révisions (même supprimé) :
 <xtermrtf> <xtermrtf>
 $ git log --all --full-history -- test $ git log --all --full-history -- test
Ligne 471: Ligne 485:
 </xtermrtf> </xtermrtf>
  
-  * Détruit la branche gigix :+  * Détruit la branche gigix localement :
 <xtermrtf> <xtermrtf>
 $ git branch -d gigix $ git branch -d gigix
 +</xtermrtf>
 +
 +  * Détruit la branche distante gigix sur le remote origin :
 +<xtermrtf>
 +$ git push -u origin -d gigix
 </xtermrtf> </xtermrtf>
  
Ligne 599: 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é).
 </note> </note>
 +
 +  * Rejoue les modifications de dev sur le sommet de la branche master :
 +<xtermrtf>
 +$ 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
 +</xtermrtf>
 +
 +  * Récupérer une sous branche d'une branche dans master :
 +Prenons le cas ci-dessous :
 +{{ :tuto:linux:interesting-rebase-1.png?nolink |}}
 +
 +Pour fusionner la sous-branche client de server dans master, on fera :
 +<xtermrtf>
 +$ git rebase --onto master server client
 +</xtermrtf>
 +
 +Ce qui donnera :
 +{{ :tuto:linux:interesting-rebase-2.png?nolink |}}
 +
 ==== merge ==== ==== merge ====
 Fusionne 2 [[#branch|branche]] et garde une trace dans [[#log|l'historique]]. Fusionne 2 [[#branch|branche]] et garde une trace dans [[#log|l'historique]].
Ligne 615: Ligne 658:
 <xtermrtf> <xtermrtf>
 $ git merge test --no-ff $ git merge test --no-ff
 +</xtermrtf>
 +
 +  * Merge une branche dans une autre sans modifier l'historique (exemple : merge la branche gigix dans la branche master) :
 +<xtermrtf>
 +$ 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
 </xtermrtf> </xtermrtf>
  
tuto/linux/git.1505670268.txt.gz · Dernière modification : 2017/09/17 17:44 de root