« Git/Améliorer sa productivité en configurant Git » : différence entre les versions

Contenu supprimé Contenu ajouté
DannyS712 (discussion | contributions)
m <source> -> <syntaxhighlight> (phab:T237267)
Ligne 18 :
Pour voir, à tout moment, votre configuration :
 
<sourcesyntaxhighlight lang="bash">
git config --list
</syntaxhighlight>
</source>
 
== Activer la coloration de la sortie par défaut ==
Ligne 28 :
Vous pouvez toutefois configurer git pour forcer ce comportement par défaut.
 
<sourcesyntaxhighlight lang="bash">
git config --global color.ui true
</syntaxhighlight>
</source>
 
== Créer des alias pour vos commandes les plus courantes ==
Ligne 37 :
 
* Exemple pour afficher les logs à un certain format :
<sourcesyntaxhighlight lang=bash>
[alias]
lg = log --graph --all --decorate
</syntaxhighlight>
</source>
 
Un alias peut aussi se créer en ligne de commande :
 
<sourcesyntaxhighlight lang="bash">
git config --global alias.graph "log --all --decorate --oneline --graph --pretty=format:"%h%x09%an%x09%ad%x09%s""
</syntaxhighlight>
</source>
 
* Retrouver la branche d'un commit en le plaçant en paramètre $1. Ex : <code>git pr 0eccb68</code><ref>https://coderwall.com/p/kxb7kg/find-a-pull-request-given-the-commit-sha</ref> :
<sourcesyntaxhighlight lang=bash>
[alias]
br = "!f() { git log --merges --ancestry-path --oneline $1..master | grep 'pull request' | tail -n1 | awk '{ print $5 }'; }; f"
</syntaxhighlight>
</source>
 
* Ouvrir les fichiers modifiés sur une branche dans un IDE (par exemple pour reprendre le travail après un checkout) :
<sourcesyntaxhighlight lang=bash>
[alias]
openfiles = !sh -c 'git show --pretty= --name-only | grep / | xargs /opt/PhpStorm-182.4129.45/bin/phpstorm.sh'
</syntaxhighlight>
</source>
 
== Références ==