Ceci est une ancienne révision du document !
Git
Mes réglages
Git log
Pour avoir un log plus détaillé que la simple commande git log , créez un alias dans le fichier ~/.gitconfig pour avoir un rendu avec un graphique. source
[alias] lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' lgf = log --graph --abbrev-commit --decorate --name-status --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' lga = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all
Ensuite pour l'afficher, il suffit d'entrer la commande git lg…
Git prompt
Pour avoir un prompt plus sympa avec des icônes qui indiques le statut de la copie de travail, utiliser bash-git-prompt.
Une fois fait, si vous voulez afficher la légende lié au symboles, tapez dans le shell :
git_prompt_help
Attention, il faut être dans un répertoire GIT
Git status
Pour lister le contenu d'un dossier untracked, modifier la variable de configuration suivante :
git config --global status.showUntrackedFiles all
L'équivalent sans cette configuration et la commande git status -u.
Modification remote
Pour lister les URL
$ git remote -v origin git://github.com/xxx/xxx.git (fetch) origin git://github.com/xxx/xxx.git (push)
Pour changer l'URL du remote
$ git remote set-url origin [new url]
Pour changer le nom du remote
$ git remote rename [old] [new]
Diverses commandes
Supprimer une branche sur le server distant
git push --delete repo branch
Déplacer master et HEAD (pour effacer les commits au dessus qui sont déjà pushé)
git rebase --onto XXX
XXX correspond au numéro de commit
Avoir une information sur la création d'une branche
git reflog --date=local | grep [branch]
D'autre alias
co = checkout
diffc = diff --color-words=.
save = !git add -A && git commit -m 'SAVEPOINT'
undo = "!f() { branch=\"[$(git rev-parse --abbrev-ref HEAD)] : SAVEPOINT\"; message=$(git log --format=format:'%s' -1); if [ \"$branch\" == \"$message\" ]; then git reset HEAD~1 --mixed; else echo \"SAVEPOINT non trouvé, annulation de la commande git undo\"; fi; }; f"
Conflit
Lors d'un merge, si l'on veut afficher l'ancêtre commun de la partie en conflit, utiliser la commande suivante et afficher le fichier
git checkout --conflict=diff3 [nom du fichier]
Merge
Lors d'un merge, si on veut ignorer les retours à la lignes, espaces et indentations des fichiers, utiliser la commande suivante :
git merge -Xignore-all-space [branch]
.gitconfig
[user] name = email = [color] # Enable colors in color-supporting terminals ui = auto [core] # Don't paginate output by default pager = cat [color "branch"] # Blue on black is hard to read in git branch -vv: use cyan instead upstream = cyan [alias] lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' lgf = log --graph --abbrev-commit --decorate --name-status --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' lga = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all co = checkout diffc = diff --color-words=. st = status [status] showUntrackedFiles = all
