Chez ouam

/home/jmfrouin

View on GitHub
31 January 2013

Configuration de git

by Jean-Michel Frouin

Toutes les commandes suivantes, ne font que, ajouter des lignes au fichier ~/.gitconfig.

Définir le rebase par défaut

git config --global --bool pull.rebase true

et activer la commande rerere :

git config --global rerere.enabled true

Ajouter la couleur à git

git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto

Créer des raccourcis

git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch

Ensuite un git co permettra de faire un checkout.

Définir son identité

Définir son nom :

git config --global user.name "Jean-Michel Frouin"

Définir son email :

git config --global user.email jm@frouin.me

Définir ses outils

Son éditeur de texte:

git config --global core.editor "vim"

Son comparateur de commit:

git config --global merge.tool "vimdiff"

Ignorer des fichiers

echo ".svn" ~/.gitignore
git config --global core.excludesfile ~/.gitignore

Cloner un dépôt en ssh

git clone user@machine.domain.com:~/project

Va créer le répertoire guide contenant le dépôt.

Sur port non standard:
Editer le fichier ~/.ssh/config

Et mettre :

Host machine.domain.com
  Port 1234

Configurer les couleurs

Dans le fichier ~/.gitconfig :

[color]
branch = auto
diff = auto
status = auto

[color "branch"]
current = yellow reverse
local = yellow
remote = green

[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold

[color "status"]
added = yellow
changed = green
untracked = cyan

NB: Largement inspiré de : http://www.kernel.org/pub/software/scm/git/docs/tutorial.html

Bonus mon fichier .gitconfig

  [user]
  name = Jean-Michel Frouin
  email = jm@frouin.me

[color]
  branch = true
  diff = true
  interactive = true
  ui = true
  status = true

[commit]
  template = /opt/gitmessage.template

[core]
  editor = vim
  excludesfile = /var/home/jmfrouin/.gitignore 
  preloadindex = true
  autocrlf = false
  whitespace = trailing-space,space-before-tab,indent-with-non-space

[alias]
  ci = commit
  co = checkout
  st = status
  ilog = log --pretty=format:'%h - %an, %ar : %s'
  glog = log --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset --> %C(magenta)%d%Creset' --abbrev-commit --date=relative
  stat = shortlog -s -n --all
  last = log -1 HEAD
  unstage = reset HEAD --

[diff]
  tool = bcompare

[merge]
  tool = vimdiff

[gc]
	auto = 0

[push]
	default = current

[filter "indent"]
	clean = indent
	smudge = cat

[pack]
	windowMemory = 500m
	SizeLimit = 500m
	threads = 1

[pull]
	rebase = true

Pour de plus amples informations sur git, un glossaire git est disponible.

tags: