Created
June 17, 2013 14:42
Revisions
-
bobmaerten created this gist
Jun 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ Voici mon dépôt git contenant la dernière version de oh_my_zsh, avec quelques commits locaux. ```bash $ cd $ZSH $ git branch -a * local master remotes/origin/HEAD -> origin/master $ git log --pretty=format:"%h %d %s" | head -4 0649746 (HEAD, local) rebase instead of git pull while upgrading d02f898 Fixed autostart of zsh plugin to my needs 0edb46d Fixed regression bug to upgrade b88b5b2 (origin/master, origin/HEAD) Merge pull request #1885 ``` Si je veux obtenir la liste des fichiers modifiés depuis le dernier commit de master, je peux faire un : ```bash $ git diff --name-only master README.textile lib/functions.zsh lib/termsupport.zsh plugins/debian/debian.plugin.zsh plugins/jira/jira.plugin.zsh plugins/postgres/postgres.plugin.zsh plugins/tmux/tmux.plugin.zsh plugins/virtualenv/virtualenv.plugin.zsh plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh tools/check_for_upgrade.sh tools/upgrade.sh ``` Par extension, récupérer la liste des répertoires : ```bash $ for d in $(git diff --name-only master); do dirname $d; done | sort | uniq . lib plugins/debian plugins/jira plugins/postgres plugins/tmux plugins/virtualenv plugins/virtualenvwrapper tools ``` pour l'utiliser dans un hook git, on peut par exemple de reprendre cette commande pour vérifier qu'un fichier dans un répertoire spécifique n'a pas été commité (voir fichier suivant du gist). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #!/bin/sh if git-rev-parse --verify HEAD >/dev/null 2>&1; then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi for FILE in `git diff --name-only $against --` ; do if [ "$(dirname $FILE)" = "lib" ] then echo 'Attention, répertoire lib modifié' exit 1 fi done exit 1